user.rb 定义了 password 虚拟属性
user.html.erb 定义了虚拟属性表单
然而输出了一下 password= 那个方法没有执行....23333
请指教
巴扎黑2017-04-24 09:11:50
Because ror 4.2 is used, the correct way is to add your virtual attributes to :permit(:virtual attribute name)
阿神2017-04-24 09:11:50
I haven’t used erb much, but are you sure that this method will be called in the template? password=
I am used to using
callbacks for this kind of needs...before_create
怪我咯2017-04-24 09:11:50
Ruby on Rails does not need to write attr_accessor directly.
But you need to use strong-parameters. Refer to the following writing method and add password to the whitelist:
http://edgeguides.rubyonrails.org/action_controller_overview.html#stro...