When login fails, it redire开发者_高级运维cts to session path and i get that Exception caught error and it says
Unknown action No action responded to show. Actions: accessdenied, checkroles, create, destroy, new, renderoptionalerrorfile, rolerequirements, and role_requirements=
sessions_controller
def new
end
def create
logout_keeping_session!
user = User.authenticate(params[:login], params[:password])
if user
# Protects against session fixation attacks, causes request forgery
# protection if user resubmits an earlier form using back
# button. Uncomment if you understand the tradeoffs.
# reset_session
self.current_user = user
new_cookie_flag = (params[:remember_me] == "1")
handle_remember_cookie! new_cookie_flag
redirect_back_or_default('/')
flash[:notice] = "Logged in successfully"
else
note_failed_signin
@login = params[:login]
@remember_me = params[:remember_me]
render :action => 'new'
end
end
protected
# Track failed login attempts
def note_failed_signin
flash[:error] = "Couldn't log you in as '#{params[:login]}'"
logger.warn "Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}"
end
end
routes
map.logout '/logout', :controller => 'sessions', :action => 'destroy'
map.login '/login', :controller => 'sessions', :action => 'new'
map.register '/register', :controller => 'users', :action => 'create'
map.signup '/signup', :controller => 'users', :action => 'new'
map.resources :users
map.resource :session
Did you try a redirect_to
instead of a render?
Upon further inspection, this might have to do with your map.resource
call. When using a singular map.resource
(instead of plural), no default route is created for index
.
You might want to do a rake:routes
to see your available routes, and check the info for map.resource
here.
精彩评论