을 나는 이런 식으로했다 :PARAM가 없거나 값이 비어 : user_club - 레일
보기 클럽
<button>
<%= link_to "Join Club", user_clubs_path(:user_id => current_user.id, :club_id => @club.id, :join_date => Date.current), :method => :post %>
</button>
컨트롤러 user_clubs을
def create
@user_club = UserClub.new(user_club_params)
respond_to do |format|
if @user_club.save
format.html { redirect_to @user_club, notice: 'User club was successfully created.' }
format.json { render :show, status: :created, location: @user_club }
else
format.html { render :new }
format.json { render json: @user_club.errors, status: :unprocessable_entity }
end
end
end
def user_club_params
params.require(:user_club).permit(:user_id, :club_id, :join_date) --->**Error here**
end
오류 정보
응용 프로그램/컨트롤러/user_clubs_controller.rb : 75 : user_club_params' app/controllers/user_clubs_controller.rb:28:in
에서 '만들 요청
Parameters:
{"_method"=>"post",
"authenticity_token"=>"5Grhb+LIGt9B8XbnEcvg7BZQlDE935KO/aeikZoqxYs=",
"club_id"=>"1",
"join_date"=>"2014-11-17",
"user_id"=>"2"
}
클럽 및 UserClubs이 다르다. 클럽은 사람들의 팀을 대표하는 모델이며, user_clubs는 사용자와 클럽 간의 다 - 대 - 다 관계를 나타내는 모델입니다.
먼저, user_clubs_path에 대한 호출이 인수에 이어 어떻게 user_clubs 컨트롤러 만들기 작업으로 이동해야하는지 알 수 있습니까?
둘째, 객관적인 문제인 이유는 무엇입니까?
, 그것은 de _form을 채울 필요없이 리소스를 만드는 방법입니다. 맞습니까? –
예, 레일스 매직의 종류 :),': method => : post'를 추가하면 Rails는 링크를 내부 js를 통해 양식으로 변환합니다. http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to – markets
감사합니다. 나는 기초를 배우고 있으며 자바와 C와 같은 프로그래밍 언어에서 왔고 처음에는 그 추상을 추상화하지 않았다. 다시 한번 감사드립니다 :-) –