On Thu, May 22, 2008 at 5:33 PM, summea
<summea-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> I also have another controller (pages) where each "page" is
> essentially an HTML-like page. Each "page" is filed underneath a
> certain "category". All of this seems to work at the moment.
But I
> can''t seem to find any information on how to display a
"page" as if it
> were filed (like an HTML file in a web directory.) So that it would
> look something like this:
>
> http://www.site.com/pages/category_a/category_b/category_c/page
>
>
> Maybe this is the point where you (the reader,) are wondering, "why is
> he doing it THIS way...?" And if so, is there a better way to do
> this? I realize that if I eventually need to move a page to another
> "category" the URL where it was at previously will now be broken.
But
> for a simple website application it works for me.
>
> Is there a way to have a route that allows for potentially unlimited
Yep, you can use route globbing:
map.file ''*directory/:file'', :requirements => {:file =>
/\w+\.\w+/}
map.directory ''*directory''
Then to generate lins to these URLs:
directory_path([''path'', ''to'',
''dir''])
file_path([''path'', ''to'',
''dir''], ''file.txt'')
The trick with globbing is that you need to have parts in your URL that
either conform to some requirements, or have a unique piece in them.
Otherwise, any route will match that route.
Hope that helps.
Brandon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---