'follow_form'이라는 부분이 있는데, 다른 하나는 player_infos
으로 표시됩니다. 나는 "플레이어 # 쇼`에 _player_infos
을 표시하고 있습니다.Aails 양식이 Rails3과 함께 자동으로 전송됩니다.
내 문제는 내가 players/show
에 갈 때하는 관계가 자동으로. 내 말은, players/_follow
의 양식이 자동으로 전송됩니다 만든 것입니다.
이 follow_form
부분에는 다음이 포함
<% unless current_user == @player %>
<div class="follow_form">
<% if current_user.following?(@player) %>
<%= render 'players/unfollow' %>
<% else %>
<%= render 'players/follow' %>
<% end %>
</div>
<% end %>
내 _follow
:
<%= form_for current_user.relationships.build(:followed_id => @player.id),
:remote => true do |f| %>
<div><%= f.hidden_field :followed_id %></div>
<div class="actions"><%= f.submit "Suivre" , :class=>"grid_13 cursor" %></div>
<% end %>
내 RelationshipsController에 포함 된 정확한에 그래서 편집
확인 : 관계도 만들어 왜 그렇게
class Player < ActiveRecord::Base
def follow!(followed)
relationships.create!(:followed_id => followed.id)
end
end
, 나는 이해할 수 없다 :
def create
@player = Player.find(params[:relationship][:followed_id])
current_user.follow!(@player)
respond_to do |format|
format.html { redirect_to @player }
format.js
end
end
그리고 follow!
이에 의미 제출 버튼을 클릭하지 않으면.
자세한 정보가 필요하면 알려주십시오. 감사합니다.