class PlayerProfile < ActiveRecord::Base
has_many :playing_roles
has_many :player_roles, through: :playing_roles
accepts_nested_attributes_for :playing_roles, :allow_destroy => true
end
class PlayingRole < ActiveRecord::Base
belongs_to :player_roles
belongs_to :player_profile
end
class PlayerRole < ActiveRecord::Base
has_many :playing_roles
has_many :player_profiles, through: :playing_roles
end
Schema.rb체크 박스 대다 나는 각각의 역할 플레이어가 할 수있는 연주에 대한 확인란을 보여줄 필요가 관계
create_table "player_profiles", force: true do |t|
t.integer "user_id"
t.string "firstname"
t.string "lastname"
t.date "birthdate"
t.string "favorite_team"
t.string "mobile"
t.string "address"
t.string "lang"
t.string "team"
t.integer "weight"
t.integer "height"
t.text "biography"
t.string "idols"
t.datetime "created_at"
t.datetime "updated_at"
t.string "nationality"
end
add_index "player_profiles", ["user_id"], name: "index_player_profiles_on_user_id", using: :btree
create_table "player_roles", force: true do |t|
t.string "name"
end
create_table "playing_roles", force: true do |t|
t.integer "player_profile_id"
t.integer "player_role_id"
t.datetime "created_at"
t.datetime "updated_at"
end
. 확인 체크 박스는 "playing_roles"relashionship
collection_check_boxes 사용에 대한 기록을 의미 Rails4에서을
UPDATE
내가 사용하는 경우 :
<%=collection_check_boxes(:player_profile, :playing_role_ids, PlayerRole.all, :id, :name)%>
: playing_role_ids을 나는이 오류
관계에 대한 레코드를 찾는 것 같지만 레코드가 존재하지 않는다면 관계가 없으며 선택란을 선택 해제해야 함을 의미합니다. http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_check_boxes 레일 3.X에서
simpleform 또는 formtastic과 같은 것을 사용하고 있습니까? 아니면 정상적인 레일이 헬퍼를 형성합니까? –
일반 레일 헬퍼. Formstatic/simpleform이이 경우 더 좋을 수 있습니까? – sparkle
내 대답 –