[英]ActionController::RoutingError (uninitialized constant)
I have a problem with my road and I do not understand why he told me "Dashboard::TasksController " because in my controller file contains the file dashbaord / tasks.rb我的道路有问题,我不明白他为什么告诉我“Dashboard::TasksController”,因为在我的控制器文件中包含文件 dashbaord/tasks.rb
class TasksController < ApplicationController
def add_task
@t = "test"
end
end结尾
in my config / routes file I did this在我的配置/路由文件中我做了这个
match '/dashboard/add-task' => "dashboard/tasks#add_task", via: [:get, :post]
in folder view view/dashbaord/tasks/add_task.html.erb在文件夹视图视图/dashbaord/tasks/add_task.html.erb
So I do not see or is my mistake.所以我没有看到或者是我的错误。
Thank you谢谢
Firstly, your controller file should be named tasks_controller.rb
.首先,您的控制器文件应命名为
tasks_controller.rb
。 Secondly, your TasksController
should be namespaced:其次,你的
TasksController
应该被命名空间:
class Dashboard::TasksController < ApplicationController
# content
end
就我而言,我没有使用 Rails CLI 生成控制器,因此我输入了错误的文件名...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.