オプションで rails has_many を使用していますが、ここで何か間違っているかどうかわかりません。プレーヤーにシーズンを作成してもらいたいのですが、プレーヤーがシーズンを作成しようとすると、作成したすべてのシーズンの選択メニューが年/新しい年に表示されます。これまでのところ、その部分はうまく機能していますが、プレーヤーがシーズンレールを保存しようとすると、それは保存されません. 自分の関連付けが正しいのか、それとも何か間違っているのかわかりません。これが機能しない理由はありますか?
エラー
No association found for name `season_year'. Has it been defined yet?
シーズン.rb
class season < ActiveRecord::Base
belongs_to :player
has_many :quarters
has_many :years , :through => :quarters
attr_accessible :season_year_attributes
accepts_nested_attributes_for :season_year
end
四半期.rb
class Quarter < ActiveRecord::Base
belongs_to :player
belongs_to :year
belongs_to :season
end
年.rb
class Year < ActiveRecord::Base
attr_accessible :season_year, :season_name
has_many :quarters
has_many :seasons, :through => :quarters
end
player.rb
class player < ActiveRecord::Base
has_many :seasons, :through => :quarters
has_many :years, :through => :quarters
end
_season-form.html.erb
<%= form_for(@season) do |f| %>
<div class="field">
<%= f.label :season %>
<%= f.text_field :season_name %>
</div>
<%= f.fields_for :years do |year| %>
<%= select("season", "year_ids", Year.all.collect {|p| [ p.season_year, p.id ] }, { :include_blank => true }) %>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>