zend modules like in rails
Asked Answered
R

2

0

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 things in rails ?

Thanks in advANCE

Retinue answered 10/3, 2011 at 19:11 Comment(0)
F
2

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

Fury answered 10/3, 2011 at 20:54 Comment(0)
N
0

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.

Northrup answered 10/3, 2011 at 20:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.