i'm using Devise for registrations. Devise uses my User model to create new users. However, i want to add some custom values to the user model upon registration. I thought something like a before_create filter on the User model, but i'm not sure that is the b开发者_运维技巧est choice.
How would you do it ? (without hidden form fields, i need to customize more than that)
You can add any attribute/field to a Devise authentication table like you do for other table in the database. If its not about validating data, use after_create
Update:
Like if you want to add extra field full_name comprised of first_name and last_name, you can write
after_create :populate_full_name
def populate_full_name
self.full_name = "#{self.first_name} #{self.last_name}"
end
精彩评论