Rails開発は初めてで、MongoDBも始めています。
Rails を使用した複雑なフォームに関するこのRailscastチュートリアルに従っていますが、データベースとして MongoDB を使用しています。子を持つドキュメントを挿入し、編集フォームにデータを取得するのに問題はありませんが、更新しようとするとこのエラーが発生します
false:FalseClass の未定義メソッド `assert_valid_keys'
これは私のエンティティクラスです
class Project
include MongoMapper::Document
key :name, String, :required => true
key :priority, Integer
many :tasks
after_update :save_tasks
def task_attributes=(task_attributes)
task_attributes.each do |attributes|
if attributes[:id].blank?
tasks.build(attributes)
else
task = tasks.detect { |t| t.id.to_s == attributes[:id].to_s }
task.attributes = attributes
end
end
end
def save_tasks
tasks.each do |t|
if t.should_destroy?
t.destroy
else
t.save(:validate => false)
end
end
終了 終了
class Task
include MongoMapper::EmbeddedDocument
key :project_id, ObjectId
key :name, String
key :description, String
key :completed, Boolean
belongs_to :project
attr_accessor :should_destroy
def should_destroy?
should_destroy.to_i == 1
end
end
ここで何が起こっているか知っている人はいますか?ありがとう