0
레일 4에 리디렉션이 있습니다. 특정 상황에서 지정된 페이지로 리디렉션해야합니다. 리디렉션해야하는 페이지가 이전 페이지가 아니기 때문에 역방향 리디렉션이 작동하지 않으며 사용자가 링크를 클릭 할 때이 페이지로 리디렉션 만하면됩니다. 코드 : 보기 위치를 사용자가 클릭 :현재 페이지로 리디렉션하지 않음
나는 그 링크를 클릭 할 때 리디렉션해야 할 곳으로<li >
<%= link_to new_admin_wine_path do %>
<span>
Cadastrar um novo vinho
</span>
<% end %>
</li>
페이지 : new_admin_wine_path
컨트롤러 :
def store_location
return unless request.get?
if (request.path != new_user_session_path &&
request.path != new_user_registration_path &&
request.path != new_user_password_path &&
request.path != edit_user_password_path &&
request.path != "/:locale/users/confirmation(" &&
request.path != destroy_user_session_path &&
!request.xhr?) # don't store ajax calls
session[:previous_url] = request.fullpath
end
end
def after_sign_in_path_for(resource)
session[:previous_url] || root_path
end
감사합니다. 그거야. –