すでにユーザーモデルを作成しています。既存のユーザーモデルでデバイスをどのように構成すればよいのでしょうか。そうは言っても、追加のルートを設定する必要がありますか、それともユーザーメソッドで属性にアクセスできるようにする必要がありますか。
これまでのユーザーモデルは
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 < ActiveRecord::Migration
def change
change_table :users do |t|
t.string :encrypted_password, :null => 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