私はまだRailsに比較的慣れていないので、ご容赦ください。パーシャルのみをレンダリングするのではなく、パーシャルを更新してページにとどまるにはどうすればよいですか?
で_interaction.html.haml:
%div.vote_up.pull-left
= link_to('', vote_up_deal_path(deal), :method => :post,
:class => 'icon-thumbs-up interact_button', :id => "vote_up_#{deal.id}")
「votes.js」では:
$.ajax({
タイプ: 'POST',
URL: '/deals/' + id + '/vote_up',
成功: 関数() {
//何かをする
}
});
私の中でdeals_controller.rb:
defvote_up
user_signed_in の場合?
current_user.vote_exclusively_for(@deal = Deal.find(params[:id]))
render :partial => 'deals/partials/interaction', :locals => {:deal => @deal}
終わり
終わり
これにより、ページにリダイレクトされ、AJAX 要求のように更新するのではなく、部分的にレンダリングされます。