Parameters/methods in models in rails
I've added an extra method to my model in rails, let's just say it is:
def s开发者_运维问答ubscribed
true
end
If I create a form with:
<%= f.check_box :subscribed %>
it correctly prints a ticked checkbox, but on submission of the form it says
unknown attribute: subscribed
What am I doing wrong?
Add an attribute accessor like this:
class MyModel
attr_accessor :subscribed
end
精彩评论