views:

113

answers:

2

Hi

Im having issues with RESTful URLs in Rails.

I have site.com/services url, and I want to have subpages under that category, thats it: site.com/services/arquitecture, site.com/services/plumbing, etc.

The pages that im serving under that category are "static" .rhtml files and I would want them to be on the same controller.

Is there a way of doing this? I've tried nested resources but I find it hard to fully understand.

Thanks

A: 

Resources weren't built for serving static pages. Use regular, non-RESTful routes where you can define exactly which URLs maps to which controller and action.

henning-koch
A: 

Here is one simple approaches for this.

Assuming you have a "services" resource in your routes.rb, you don't need nested resources - just add a :members hash to your route definition:

map.resources :services, :member => {:plumbing => :get, :arquitecture => :get, ...}

then define empty actions in your services controller for each static page. You can use page caching for those pages if they are truly static & Rails will bypass the controller altogether after the 1st call to each action.

simianarmy