simple_formと連携するのに問題があります。フォームでの関連付けができません。
私は以下のモデルを持っています。
class Product < ActiveRecord::Base
belongs_to :Retailer
end
と
class Retailer < ActiveRecord::Base
has_many :Products
end
マイ形部分(製品/ _form.html.erb)それは関連せずに動作しますが、それを私は次のように取得するには、次
<%= simple_form_for(@product) do |f| %>
...
<% f.input :currency %>
<% f.association :retailer %>
...
が含まれていますエラー:
undefined method `retailer_id' for #<Product:0x007ffbe0f7d530>
私は(明らかに)これに対してかなり新しいですが、これを解決することはできませんでした。
編集:チェック済みマイグレーションを実行していて、最新の状態です。 Retailerテーブルにはidカラムがあります!
> Retailer.all
Retailer Load (0.2ms) SELECT "retailers".* FROM "retailers"
=> [#<Retailer id: 1, name: "Retailer 1" etc...
chemaファイル:
ActiveRecord::Schema.define(:version => 20120308195055) do
create_table "alerts", :force => true do |t|
t.string "url", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "products", :force => true do |t|
t.string "title", :null => false
t.integer "price_cents", :default => 0, :null => false
t.string "currency", :null => false
t.string "asin", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "retailers", :force => true do |t|
t.string "name", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end