Rails Catch All Route URL Helpers?
- by viatropos
If I have a catch-all-route like this:
match '*request_path' => "pages#show", :as => :page
...and the pages can be arbitrarily nested, how do I make it so I can use the url helper methods?
If I have a page structure like this:
/about
/about/people
/about/story
/about/story/in-depth
Then I want to be able to write page_path(@page) and get /about/story/in-depth for the hypothetical "In Depth Story" page. But instead I'm just getting /in-depth.
If I override Page#to_param, and do something like this:
def to_param
result = ""
if parent
result << parent.to_param
result << "/"
end
result << super
end
... it returns an encoded string like this:
/about%2Fstory%2Fin-depth
Is there a way to make this work?