當用戶未登錄時,它在顯示"You need to sign in or sign up before continuing"
時,他試圖執行需要身份驗證的操作。當使用Devise身份驗證登錄後,它顯示ajax請求的空白頁面
這就是我想要的,所以沒關係。
然而,問題在於,它需要用戶在空白頁(這是AJAX請求的URL,因此它是空白)時後,他簽約。
是否有可能讓他留在同前一頁,並讓它執行與remote=>true
阿賈克斯請求?
我該如何處理這類問題?
[UPDATE]
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 %>
這很難理解你的問題。在你的應用中,有一個Ajax操作。如果用戶在登錄之前調用它,他會被帶到一個空白頁面?這是你的問題嗎?你可以粘貼控制器動作和HTML鏈接是造成這個問題.. – manoj
@manoj對不起,我的可憐的解釋。如果用戶在登錄前調用Ajax操作,則需要他登錄頁面。然後,他可能會輸入他的電子郵件和密碼,然後登錄。但是,登錄後顯示空白頁。我將粘貼我的代碼。請稍等一下。 – HUSTEN
@manoj對不起,延遲迴復。我更新了我的問題:) – HUSTEN