your problem is that you are calling User.make_admin_if_none
and in there you are asking self.find_by_role(admin) now, as this is a class-method self would be the user-class, but not an instance of it, which means it is not a single user and thus cannot have the role 'admin'. therefor your if-clause always gets evaluated to false and you create a new user every time someone hits that button. make it an instance-method (= get rid of the 'self.' in method- definition and adjust the logic accordingly). and call it like this user = User.authenticate(params[:username], params[:password]) user.make_admin_if_none hope this helps... --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

