我有2個控制器:Rails的路線:定義根命名空間
app/
/controllers
posts_controllers.rb
/mobile
posts_controllers.rb
和我的routes.rb看起來是這樣的:
root :to => "posts#index"
resources :posts
namespace :mobile do
root :to => "posts#index"
resources :posts
end
,但是當我訪問/mobile
,它反正顯色指數第一個控制器的頁面,也試過這個:
namespace :mobile do
root :to => "mobile/posts#index"
resources :posts
end
但它給我錯誤:uninitialized constant Mobile::Mobile
我想渲染第二個控制器的索引頁,我該怎麼做?
編輯
通過輸入/移動我想渲染設在這裏的文件:
app/
views/
/mobile
/posts
index.html.erb
但它在這裏撕心裂肺文件:
app/
views/
/posts
index.html.erb
你做得很好,只要檢查你的'controllers/mobile/posts_controller.rb'類是否類似於'class Mobile :: PostsController
jan267