Update a user model attribute during a lifecycle transition

7 views
Skip to first unread message

Andy Waite

unread,
Dec 19, 2009, 5:34:29 PM12/19/09
to Hobo Users
When I try to update an attribute within a transition, such as in the
(simplified) example below, I get the error "Current password is not
correct". What's the correct way to do this?

transition :activate, { :inactive => :active },
:update =>
[ :name, :password, :password_confirmation ],
:params =>
[ :name, :password, :password_confirmation ],
:available_to => :key_holder do
self['name'] = "blah"
self.save!
end


Andy

Bryan Larsen

unread,
Dec 22, 2009, 11:45:00 AM12/22/09
to hobo...@googlegroups.com
I think you've exposed a bug here. My current theory is that your code
ends up triggering save! twice -- it runs successfully on the first
save, but on the second save, current_password is still set to your old
password, and the validation fails.

If you have more information, please add it to the bug I created:
https://hobo.lighthouseapp.com/projects/8324-hobo/tickets/590-validate_current_password_when_changing_password-fails-on-second-save

thanks,
bryan

> --
>
> You received this message because you are subscribed to the Google Groups "Hobo Users" group.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
>
>
>

Reply all
Reply to author
Forward
0 new messages