[Rails] Solved: Troubles with bcrypt-ruby
It turned out the problem was in controller code.
ActiveModel::SecurePassword implements password= method, which is used
to set password_digest field.
so: calling record.password= sets password_diggest field.
But as I have written I am using my own form system, which uses single
controller for editing all models. I had something like this in the
controller:
fields.each do |k,v|
@record[v['name']] = params['record'][v['name']]
end
which leads to when v is 'password'
@record['password'] = params['record']['password']
which works perfectly OK with mongoid and adds password attribute to
document.
And of course doesn't call @record.password= method at all.
--------------------
Solution is to use send("password=", value) method of @record.
@record.send( "#{v['name']}=", params['record'][v['name']] )
Hope this will save somebodies hours in future.
by
TheR
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home