MongoMapper と Formtastic を連携させるのに苦労しています。
問題を特定するために、最小限のコードでダミー アプリケーションを作成しました。
2 つの主要なモデル (キャビネットとデバイス) があり、それらの間には "many/belongs_to" の関係があり、キャビネット リソースのスキャフォールディングされたコントローラーがあります。
単純な「キー」フィールド宣言以外のものを使用して非常に基本的なフォームスタティック フォーム (以下を参照) をロードすると、コントローラで「NoMethodError」例外が発生し、次のエラー「Device:Class の未定義メソッド `scoped'」が表示されます。 _form.html.haml パーシャルの 4 行目を参照します。
これについて何か考えはありますか?Google や StackOverflow で役に立つものは見つかりませんでした...
アプリ/モデル/キャビネット.rb
class Cabinet
include MongoMapper::Document
safe
key :label, String, :required => true
many :devices
end
アプリ/モデル/device.rb
class Device
include MongoMapper::Document
safe
key :label, String, :required => true
belongs_to :cabinet
end
アプリ/ビュー/キャビネット/_form.html.haml
= semantic_form_for @cabinet do |f|
= f.inputs do
= f.input :label
= f.input :devices
= f.actions
スキャフォールディングされたコードにはまったく触れていないため、スキャフォールディングされたコントローラーは含めませんでした。
使用される宝石のバージョン:
Gems included by the bundle:
* actionmailer (3.2.7)
* actionpack (3.2.7)
* activemodel (3.2.7)
* activerecord (3.2.7)
* activeresource (3.2.7)
* activesupport (3.2.7)
* arel (3.0.2)
* bson (1.6.4)
* bson_ext (1.6.4)
* builder (3.0.0)
* bundler (1.1.5)
* coffee-rails (3.2.2)
* coffee-script (2.2.0)
* coffee-script-source (1.3.3)
* erubis (2.7.0)
* execjs (1.4.0)
* formtastic (2.2.1)
* haml (3.1.6)
* haml-rails (0.3.4)
* hike (1.2.1)
* hpricot (0.8.6)
* i18n (0.6.0)
* journey (1.0.4)
* jquery-rails (2.0.2)
* json (1.7.4)
* libv8 (3.3.10.4)
* mail (2.4.4)
* mime-types (1.19)
* mongo (1.6.4)
* mongo_mapper (0.11.2)
* multi_json (1.3.6)
* plucky (0.5.1)
* polyglot (0.3.3)
* rack (1.4.1)
* rack-cache (1.2)
* rack-ssl (1.3.2)
* rack-test (0.6.1)
* rails (3.2.7)
* railties (3.2.7)
* rake (0.9.2.2)
* rdoc (3.12)
* ruby_parser (2.3.1)
* sass (3.1.20)
* sass-rails (3.2.5)
* sexp_processor (3.2.0)
* sprockets (2.1.3)
* therubyracer (0.10.1)
* thor (0.15.4)
* tilt (1.3.3)
* treetop (1.4.10)
* tzinfo (0.3.33)
* uglifier (1.2.7)