Emmek on Rails wrote:
I have a model Page in my application that acts_as_tree. I want this
model to keep whole structure of website.
Then I would strongly suggest awesome_nested_set instead of
acts_as_tree. It makes it possible to use the DB *much* more
I have some root nodes: home,
contact, articles, etc. and the possibility of adding children to them.
I want to access these pages using slugs (Page model and new/edit forms
have such attribute/field). In show action of pages controller:
@page = Page.find_by_slug(params[:slug])
raise ActiveRecord::RecordNotFound, "Page not found" if @page.nil?
@page = Page.find(params[:id])
map.connect ':slug', :controller => 'pages', :action => 'show'
Everything works well at the first level but how to access children
pages using hierarchy of the tree and slugs?
I'm not sure. You might need to use a *glob route for the page path,
then do your own parsing.