I wonder how you guys handle content pages? Often described as “static”
pages.
However, I don’t like to call them “static” because these pages often do
use
some minor dynamic content.
This is what I like to think of as the “website” part of the web
application. Content that does not have complex logic behind it.
I had to handle it in the past, and at the time I just created a pages
controller and each action would be a “page”. I would then create custom
routes as alias to each page, such as:
(photo-gallery is exclusive, static, content-only sub-section of
fast-foods
and has nothing to do with a photo-gallery application other than
advertising this service)
I’m not sure on how I could best handle situations like this. Maybe
Rails
has a CMS plugin or something that helps in managing static pages?
If you ever had to deal with a situation like this, please, share your
experience and thoughts!
I use Radiant CMS. I haven’t yet needed to marry it with a Rails
application but I believe it can be done - there are a couple of
extensions for Radiant that support it.
To handle a limitless number of custom page urls, I use a catch-all
route at the end of config/routes.rb:
map.path ‘*url’, :controller=>‘paths’, :action=>‘show’,
:conditions=>{:method=>:get}
Custom urls using this route will be overridden by the other routes in
routes.rb, and any files in public/ that match the url.
My paths controller manages Path objects, which use polymorphic
belongs_to relations to attach arbitrary paths (relative to my web-
server root) to any displayable object (in my case, this includes
things like Pages and Events).
My code for this is part of my Wayground project, viewable at:
Of particular interest are:
app/controllers/paths_controller.rb
app/controllers/pages_controller.rb
app/models/page.rb
app/models/path.rb
I should probably pull my path handling stuff out into some sort of
acts_as_custom_url plug-in. Will post to this list if I do get around
to that.