著者クラスがあります:
class Author < ActiveRecord::Base
def to_s
name
end
end
定義to_sすることで私はできますがputs Author.first、できませんputs Author.first.rjust(10):
NoMethodError: undefined method `rjust' for #<Author:0x21eb5d4>
to_sこのような場合、Rubyが文字列メソッドの前に自動的に試行したほうがよいのではないでしょうか。この動作を取得する方法はありますか?