How to information of user of devise such as user's address in registration place?
How to add a field such as address and other information of user that created by devise in registration place?
By using another table? or set a attr in model?
开发者_JS百科I have look through the documentation and found nothing, can anyone help me out?
You can either create separate models/migrations for additional fields and link them together (especially addresses go well in a model) or you add the fields to the devise migration directly. This is a devise migration I use for a small University project:
def self.up
create_table(:students) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.token_authenticatable
t.string :name
t.string :studentNumber
t.references :faculty
t.timestamps
end
And the related line in the model:
attr_accessible :studentNumber, :email, :name, :faculty, :password, :password_confirmation
精彩评论