Subject: [Rails] How to handle static pages?
So in true Summer of Rails fashion I am trying to build my first Ruby
on Rails application, but what I haven't been able to find any
information on is how to handle my gosh darn static pages. For example
my About page. I believe I should keep it handled in Rails so that it
can use the standard template, but I don't know where to define it and
put the HTML. Thanks in advanced for any help!
You can put them anywhere in your rails 'public' subdirectory.
In my case, I generally want one site template that I can change in one
place, so I tend to put the content into a controller.
For example, my welcome controller has an about action, and a view that
renders the static data. Production Rails can cache this so that the
web server can serve it on subsequent requests.
What's a bit more annoying is protecting static content. In certain
cases, I only want to emit content if the user is logged in and has a
particular role. /public is no good in this case, as by definition, it
In this case, I have a special route that always sends to controller
protected, method render_static. The send_file command is needed, and
you have to keep track of content types to boot. You didn't say if this
was what you wanted, so I haven't elaborated much. Let me know if you
need more info.