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!

-Bradly

Bradly wrote:

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!

-Bradly   

I just have a controller that handles all 'static' pages, wrapping the html from the view in the layout then making sure it is cached. This means I have to remove the cached page by hand which is fine for small sites. If and when I never need something like this on a larger site I would come up with a cache clearing and regenerating solution.

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!

-Bradly

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 bypasses rails.

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.

HTH.

Regards, Rich