Ruby on rails 设计登录后不重定向

Ruby on rails 设计登录后不重定向,ruby-on-rails,ruby,ruby-on-rails-3,devise,Ruby On Rails,Ruby,Ruby On Rails 3,Devise,我是rails世界的新手,我想得到一些帮助,我运行Desive gem,工作完美,我只是在登录后遇到了一个小问题,我没有得到想要的页面,总是重定向到我的索引页面,你们能给点帮助吗 关于视图:我有用于仪表板和索引的索引文件 这是我的代码: routes.rb Rails.application.routes.draw do devise_for :users resources :dashboard root to: "home#index" dashboard_controller

我是rails世界的新手,我想得到一些帮助,我运行Desive gem,工作完美,我只是在登录后遇到了一个小问题,我没有得到想要的页面,总是重定向到我的索引页面,你们能给点帮助吗

关于视图:我有用于仪表板和索引的索引文件

这是我的代码:

routes.rb

Rails.application.routes.draw do
  devise_for :users
  resources :dashboard
  root to: "home#index"
dashboard_controller.rb

class DashboardController < ApplicationController
  before_filter :authenticate_user!

  def index    
  end
end
class HomeController < ApplicationController
  def index
    if user_signed_in?
      redirect_to :controller=>'dashboard', :action => 'index'
    end
  end
end
 def after_sign_in_path_for(resource)
     dashboard_index_path
   end

谢谢,在您的应用程序控制器中添加以下方法:

  def after_sign_in_path_for(resource)  
     dashboards_path #edited
  end
有关更多详细信息,请参见以下内容

编辑

您的应用程序控制器必须如下所示

class ApplicationController < ActionController::Base
   # Prevent CSRF attacks by raising an exception.
   # For APIs, you may want to use :null_session instead.
   protect_from_forgery with: :exception

   def after_sign_in_path_for(resource)
     dashboard_index_path
   end

end

class ApplicationController
试试这个

redirect_to url_for(:controller => :dashboard, :action => :index)
class仪表板控制器
为什么在“仪表板控制器”和“主控制器”中有“结束”在过滤器之前,请将其删除并添加到文件末尾


其次,使用
重定向到dashbaord\u路径
而不是
重定向到:controller=>'dashboard',:action=>'index'

谢谢您的回复,我尝试了以下方法:'def after\u sign\u in\u path\u for(resource)'redirect\u to:controller=>'dashboard',:action=>'index'end'仍然没有重定向,直到无法工作:(,这就是我在终端上看到的:它应该可以工作,你能展示你的应用控制器编解码器类ApplicationControllerredirect_to url_for(:controller => :dashboard, :action => :index)
class DashboardController < ApplicationController
**end**
before_filter :authenticate_user!

def index    
end