开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜