Can someone explain the following code to me?

前端 未结 5 1738
故里飘歌
故里飘歌 2021-01-20 05:59

I am following along with the Rails 3 in Action book, and it is talking about override to_s in the model. The code is the following:

def to_s
           


        
5条回答
  •  旧时难觅i
    2021-01-20 06:24

    The first question mark is attribute query methods in rails. http://api.rubyonrails.org/classes/ActiveRecord/Base.html#label-Attribute+query+methods

    (provided you did not overwrite / redefine that method)

    It is a shorthand method to see if that attribute present or not.

提交回复
热议问题