How can I divide my Page into different Sections?


#1

Hello,

I have the following Problem: On my site I’d like to have different
sections like Community, Shop, etc to be accessed via domain.tld/
Community/Controller/… Its all in the same app and I am using
restful Routes and Controllers. Is there a clean way to handle that
with restful routes?

I also want to be able to know in which Section the user is and i’d
like to use some Controllers in different Sections.

Philipp


#2

Philipp,

Take a look at path_prefix:
http://api.rubyonrails.org/classes/ActionController/Resources.html

That should do what you want. You could go about it other ways as
well, but that’s probably the best approach.

Remember that “rake routes” is your best friend in this case… it
lets you see all the path mappings based upon your routes.rb
definitions.

The other way you could do this is to use namespaces. People do this
often for admin sections. You could do this for your various sections.
You have to be careful of naming conventions, though. Search here for
“admin” and/or “namespace” as I know it’s been well discussed for
quite some time.

-Danimal