views:

33

answers:

1

Hi,

I want to do something similar to the question here: http://stackoverflow.com/questions/848034/grouping-views-controllers-models-in-mvc

But in Ruby on Rails. And the catch is, Models are to be grouped in a folder, but Controllers and Views are to be put in different folders, say admin/ and store/ folders.

Tried to separate these in a project, but problem is:

  map.connect 'projects/:id', :controller => 'gallery/projects', :action => 'show'
  map.namespace(:gallery,  :active_scaffold => true) do |gallery|
    gallery.resources :projects, :comments
  end

With that, gallery_project_path(@project) returns /gallery/projects/xxx (I want it to be /projects/xxx)

Is this possible with Rails?

+2  A: 

If you just want /projects routes then map.namespace isn't the option you want. Try just specifiy the name of the controller

map.resources :projects, :controller => 'gallery/projects'

That should generate routes like these

GET /projects/:id(.:format) {:controller=>"gallery/projects", :action=>"show"}
PUT /projects/:id(.:format) {:controller=>"gallery/projects", :action=>"update"}

You should also check out the RailsGuide: Rails Routing from the Outside In. I always start there when I have routing issues.

Corey
You are a life savior you know that!Thanks a lot man
jaycode