I want to create a CMS like site where the user starts off with a some generic pages, i.e.
- homepage
- about
- contact
- etc
and from there can add child pages dynamically, for example
- homepage
- articles
- article1
- something
- something-else
- something
- article2
- article1
- articles
- about
- contact
- etc
To achieve this I'm planning on using some kind of self-referential association like
class Page < ActiveRecord::Base
belongs_to :parent, :class_name => 'Page'
has_many :children, :class_name => 'Page'
end
The one thing I'm struggling with is the route generation. Because pages can be added on the fly I need to dynamically generate routes for these pages and there is no way of knowing how many levels deep a page may be nested
So if I start off with the homepage: /
and then start adding pages i.e.
/articles/article1/something/something-else/another-thing
How can something like that be achieved with the rails routing model?