I have a user registration where a user sets his username, first_class and some other attribs. Now, there are also some other attributes that i have to set, like :str or :acc.
These attributes would probably be set in a mass assignment command like create. I would not want to do something like update_attribute on each one separately of course. Therefore, i have to make them attr_accessible.
However, i don’t want the user to set them. For instance, if the user decides to have a first_class = ‘Ranger’, i would set his :str and and not him.
My idea is that i would just save params[:first_class] or params[:username] and just explicitly set everything else in my create method for the user. Is that how you would do it ?
I’m guessing that the other attributes are pre-determined based on what the user selects as part of the registration process?
In that case, I’d add a
before_createhook to your model that calculates and assigns those attributes accordingly: