开发者

Parameters/methods in models in rails

开发者 https://www.devze.com 2023-04-10 01:44 出处:网络
I\'ve added an extra method to my model in rails, let\'s just say it is: def s开发者_运维问答ubscribed

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

精彩评论

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