ユーザーがサインインしていない場合、"You need to sign in or sign up before continuing"
認証が必要なアクションを実行しようとした後に表示されます。
それが私が望んでいる方法なので、大丈夫です。
ただし、問題は、ユーザーがサインインした後、ユーザーが空白のページ (ajax が要求した URL であるため、空白である) に移動することです。
彼を同じ前のページにとどまらせ、単に ajax リクエストを実行させることは可能remote=>true
ですか?
この種の問題をどのように処理できますか?
[アップデート]
users_controller.rb
before_filter :authenticate_user!, :only => [:follow, :unfollow]
def follow
@user = User.find_by_username(params[:id])
current_user.follow(@user)
respond_to do |format|
format.js {render :action=>"follow.js"}
end
end
見る
<% if current_user.following?(user) %>
<%= link_to(unfollow_user_path(user), :remote => true) do %>
Following
<% end %>
<% else %>
<%= link_to(follow_user_path(user) ,:remote => true) do %>
Follow
<%end%>
<% end %>