开发者

zend modules like in rails

is there a way to do modules in rails 3 like zend framework modules ? In zend framework, you have a folder 'modules' like following structure:

/application/modules/admin
/application/modules/site
/application/modules/service 

and it's routed in this way:

http://myapp.local/admin
http://myapp.local/service
http://myapp.local/ -- to site module (default).

How can I achieve this in Rails 3? There's a better way to do this type thi开发者_StackOverflow中文版ngs in rails ?

Thanks in advANCE


How about controller namespaces?

                          # URL:
resources :projects       # /projects
resources :people         # /people

namespace "admin" do      # /admin
  resources :projects     # /admin/projects
  resources :people       # /admin/people
end

namespace "service" do    # /service
  resources :what         # /service/what
  resources :ever         # /service/ever
end

Controller paths:

app/controllers/projects_controller.rb
app/controllers/people_controller.rb
app/controllers/admin/projects_controller.rb
app/controllers/admin/people_controller.rb
app/controllers/service/what_controller.rb
app/controllers/service/ever_controller.rb

More information here:

http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing


This is sounding a little like Models and Routes for Rails 3. I wouldn't say you need a specific model for Admin, that would be an extension of the User model.

The rails routing guide might put some of this in perspective.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜