更新时间:2023-01-15 21:22:35
问题是Rails期望模块中的控制器称为 Users
,因为这就是 namespace:user
的推断。也许您是想使用 scope
而不是 namespace
?
The problem is that Rails is expecting there to be a controller within a module called Users
because that's what namespace :user
infers. Perhaps you meant to use scope
instead of namespace
?
scope :path => "user" do
root :to => "users#profile"
end
注意:在这种情况下,如果您只有一种方法,使用 scope
并不明智,但是如果您有多个带有 / user
前缀的那么就可以了如果您只有一个,我会改为:
Note: in this situation if you've only got one route it would not be wise to use scope
, but if you've got multiple ones with the /user
prefix then it would be fine to. If you only had one, I would do this instead:
get '/user', :to => "users#profile"