Devise で生成したユーザーのプロファイルを作成し、これを行いました (Rails 4 で):
rails g scaffold Profile first_name:string last_name:string school:string user:references
そしてこれ:
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_one :profile, :dependent => :destroy
accepts_nested_attributes_for :profiles
end
class Profile < ActiveRecord::Base
belongs_to :user
attr_accessible :first_name, :last_name, :school #where does this go in rails 4?
end
これがこの種のことを行う正しい方法であるかどうか、または代わりに何をすべきかを知りたいですか?
また、移行を通じてこれらすべてのフィールドを User モデルに直接追加することも検討しました...
これを正しく行うためのリンクや提案は本当に役に立ちます!