I was looking at example code from the O’Reilly book on Ruby on Rails and ran across this:
def label_for(method, options={})
extra = ""
if options[:required]
extra = " <span class='required_mark'>*</span>"
end
label(:label || method) + extra + "<br />"
end
I understand that options is a hash, but how is it able to call label with just :label — shouldn’t it need to say options[:label] ?
Thanks!
Yes, I believe so, otherwise the
:labelsymbol will always be passed as amethodname tolabelhelper.