class PlayerProfilesController < InheritedResources::Base
def show
@player_profile = PlayerProfile.find(params[:id])
end
end
모델
class PlayerProfile < ActiveRecord::Base
has_many :playing_roles, :dependent => :destroy
has_many :player_roles, through: :playing_roles
end
class PlayerRole < ActiveRecord::Base
has_many :playing_roles, :dependent => :destroy
has_many :player_profiles, through: :playing_roles
end
class PlayingRole < ActiveRecord::Base
belongs_to :player_profile
belongs_to :player_role
end
show.html.erb
<%=collection_check_boxes(:player_profile, :playing_roles, PlayerRole.all, :id, :name)%>
HTML 두 개의 체크 박스
<input id="player_profile_playing_roles_1" name="player_profile[playing_roles][]" type="checkbox" value="1" class="hidden-field">
<span class="custom checkbox checked"></span>
<label for="player_profile_playing_roles_1">Striker</label>
<input id="player_profile_playing_roles_2" name="player_profile[playing_roles][]" type="checkbox" value="2" class="hidden-field">
<span class="custom checkbox"></span>
<label for="player_profile_playing_roles_2">Midfielder</label>
<input name="player_profile[playing_roles][]" type="hidden" value="">
생성 제대로 모두 표시 것 같다하지만 난 제출 버튼을 클릭 할 때 나는이 오류 얻을 :
당신이 컨트롤러 액션 코드를 추가 할 수 있습니까? –
@MichaelSzyndel done;) – sparkle
@ user1028100 전체 백 트레이스를 붙여 넣을 수 있습니까? –