Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 尝试在Rails路由中使用命名空间时获取ActionController::RoutingError uninitialized常量_Ruby On Rails_Ruby_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails 尝试在Rails路由中使用命名空间时获取ActionController::RoutingError uninitialized常量

Ruby on rails 尝试在Rails路由中使用命名空间时获取ActionController::RoutingError uninitialized常量,ruby-on-rails,ruby,ruby-on-rails-4,Ruby On Rails,Ruby,Ruby On Rails 4,我有两个控制器dashboard和posts。我正试图将帖子的:新建,:创建,:销毁,:编辑,:更新操作放在仪表板url中,就像这样仪表板/posts/new。但是,im正在与posts控制器中的新操作进行对话。不在仪表板控制器中。这是我的routes.rb文件: resources :posts, :except => [:new, :create, :destroy, :edit, :update] get 'dashboard', to: 'dash#show' namespac

我有两个控制器
dashboard
posts
。我正试图将帖子的
:新建,:创建,:销毁,:编辑,:更新
操作放在
仪表板
url中,就像这样
仪表板/posts/new
。但是,im正在与
posts
控制器中的
新操作进行对话。不在
仪表板
控制器中。这是我的
routes.rb
文件:

resources :posts, :except => [:new, :create, :destroy, :edit, :update]

get 'dashboard', to: 'dash#show'

namespace :dashboard do
   resources :posts, :only => [:new, :create, :destroy, :edit, :update]
end
get 'dashboard/posts', to: 'dash#posts'
这两个控制器是:
dash
posts

现在当我尝试访问
http://localhost:3000/dashboard/posts/new
上面写着:

ActionController::RoutingError at /dashboard/posts/new
uninitialized constant Dashboard

如何解决此问题?

找不到常量“Dashboard”。我认为问题在于,假设您有两个控制器
DashController
PostsController
,那么您有时使用
dash
,有时使用
dashboard

。 如果您想访问
名称空间
范围内的一些POST路由,则可以如下定义路由:

resources :posts, :only => [:index, :show]

get 'dashboard', to: 'dash#show'

scope :dashboard do
   resources :posts, controller: :posts ,:only => [:new, :create, :destroy, :edit, :update]
end
get 'dashboard/posts', to: 'dash#posts'

@jmromer安装了仪表板控制器,但路径是Dashboard。我将所有内容重命名为
dash
,但仍然收到相同的错误