高手们都怎么优雅的实现的?说说吧,小伙伴们!
简化一下应该是这样.....
class ApplicationController
def authenticate!
unless current_user
session[:back_url] = request.uri
redirect_to user_sessions_url
end
end
end
class UserSessionsController
def new; end
def create
redirect_to(session.delete(:back_url) || root_url)
end
end