I have a model Page in my application that acts_as_tree. I want this
model to keep whole structure of website. 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:
if params[:slug] @page = Page.find_by_slug(params[:slug]) raise ActiveRecord::RecordNotFound, "Page not found" if @page.nil? else @page = Page.find(params[:id]) end
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 need this kind of access especially in ‘Articles’ node. I’d like to
access several article using mydomain.com/articles_slug/article1_slug.
What is the nice way to do it? Could you post some helpful links or
write solution? Any help appreciated.