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 
efficiently.

> 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
> 
> And routing:
> 
>   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.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to