如何在ruby on rails上添加设计迁移到现有用户模型?
我已经创建了一个用户模型。 我想知道如何使用现有的用户模型配置设计。 话虽这么说,我是否需要设置任何其他路由或使用我的用户方法访问atttributes。
到目前为止用户模型是
class User < ActiveRecord::Base attr_accessible :email, :pic, :name, :username has_many :topics end
我对CreateUsers的迁移
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :name t.string :email t.string :username t.string :pic t.timestamps end end end
现在我打算做的就是跑
rails g migration AddDeviseColumnsToUser
并将其添加到我的迁移文件中
class AddDeviseColumnsToUser false, :default => '', :limit => 128 t.confirmable t.recoverable t.rememberable t.trackable t.token_authenticatable t.timestamps end end end
现在我想知道我应该如何设置路线或者我必须这样做? 在我的用户模型中应该可以访问哪些属性?
更新:我已经安装了Devise并配置了它
rails generate devise:install
只需在路线中添加devise_for :user
添加attr_accessible :password, :password_confirmation
有关更多信息,请查看典型的设计模型
https://github.com/johndel/Rails-Simple-CMS/blob/master/app/models/admin.rb
(很简单)
你可以简单地运行:
rails generate devise User
添加设计到用户模型。