私はhas_and_belongs_to_many
ワークアウトとグループの間に関係があります。
グループにワークアウトを追加するために使用しているcollection_select
グループがあります。
問題は、HABTM テーブルの 1 つのレコードしか変更できないため、1 つのレコードしか追加できず、そのレコードを編集できないことです。レコードを追加するにはどうすればよいですか?
何か案は?
ここにいくつかのコードがあります:
show.html.erb:
<%= form_for(@group) do |f| %>
<%= f.collection_select 'workout_ids', Workout.all, :id, :name, { :include_blank => ""} %>
<%= f.submit %>
<% end %>
.
class Workout < ActiveRecord::Base
attr_accessible :name, :exercises_attributes, :workout_exercises_attributes, :group_ids
has_and_belongs_to_many :groups
.
class Group < ActiveRecord::Base
attr_accessible :cycle_id, :name, :next_group_id, :previous_group_id, :workout_ids
has_and_belongs_to_many :workouts