1

ユーザーのスキルと必要なスキルを配列に保持するクラスをDevise内にネストしようとしていますが、フォームオブジェクトを配列に保存できないようです。

    Class User
 include Mongoid::Document
 devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable

 ## Database authenticatable
 field :email,              :type => String, :null => false, :default => ""
 field :encrypted_password, :type => String, :null => false, :default => ""



 ## Recoverable
 field :reset_password_token,   :type => String
 field :reset_password_sent_at, :type => Time

 ## Rememberable
 field :remember_created_at, :type => Time

 ## Trackable
 field :sign_in_count,      :type => Integer, :default => 0
 field :current_sign_in_at, :type => Time
 field :last_sign_in_at,    :type => Time
 field :current_sign_in_ip, :type => String
 field :last_sign_in_ip,    :type => String


 field :first_name
 field :last_name

 field :location


 index([[:skills, :desired]], :background => true)

 validates_presence_of :first_name, :last_name,  :location
 validates_uniqueness_of :first_name, :last_name, :email, :case_sensitive => false
 attr_accessible :first_name, :last_name, :email, :password, :password_confirmation,     :remember_me,  :location

embeds_one :skills
end
 class Skills
 include Mongoid::Document

 field :skills, type => String
 field :desired, type => String

 embedded_in :user 
 end 

モデルとビューを修正して、ユーザーがサインアップ時に複数のスキルと必要なスキルを追加できるようにするにはどうすればよいですか? (レール初心者です)

4

1 に答える 1

1

embeds_oneスキルの配列が必要なembeds_many場合はそうする必要があります。

于 2012-04-19T15:36:55.160 に答える