开发者

Restful Authentication Action Controller: Exception caught problem

开发者 https://www.devze.com 2022-12-11 23:49 出处:网络
When login fails, it redire开发者_高级运维cts to session path and i get that Exception caught error and it says

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号