Basic Question about Base Files

Ooooh, I’m having so much fun with Ruby on Rails.

I have the students assigning to parents, the parents are able to come
login… it’s great.

That’s the functional part. As I get more of it working I am sure I’ll
have questions about that.

Until then:

What do I do for the “static” files on the site. For every site you
build don’t you have an “About” a “Contact” and “Help” page? Things
right off the root? Right now I have them in the Application directory
and a route points ‘/:action’ to :controller => Application (or
something like that, I’m home now instead of in my office).

I want them to all have the layout from the rest of the site,
obviously.

Is there a usual method for this?

Thanks,
–Colin

I have the students assigning to parents, the parents are able to come
login… it’s great.

Rails rules like no web platform has ruled before. Welcome to the inner
circle who no longer need to be told that!

Now how are your unit tests?

What do I do for the “static” files on the site. For every site you
build don’t you have an “About” a “Contact” and “Help” page? Things
right off the root? Right now I have them in the Application directory
and a route points ‘/:action’ to :controller => Application (or
something like that, I’m home now instead of in my office).

I never heard of the Application object used directly as a controller.

Put them in the most convenient app/view/controller/ folder, and name
them
all .rhtml. Don’t bother to write their actions, and access them by
default
route - /controller/help, /controller/contact, etc.

Or put them, as raw html, in /public/, and link to them from /. But this
requires the .html extension, which is tacky.


Phlip

On Oct 16, 2007, at 10:37 PM, Colin S. wrote:

What do I do for the “static” files on the site. For every site you
build don’t you have an “About” a “Contact” and “Help” page? Things
right off the root? Right now I have them in the Application directory
and a route points ‘/:action’ to :controller => Application (or
something like that, I’m home now instead of in my office).

I want them to all have the layout from the rest of the site,
obviously.

Is there a usual method for this?

My understanding is you still need to (or normally would) use
controller/action.

So if you put those at /company/about, /company/contact you would
still create a Company controller, it just wouldn’t do very much.

As for giving all pages the same look, I’ve been exploring how to do
this in Rails, and just finished writing an article about it (still
some unanswered questions, but I’ll get to those).

http://gregwillits.wordpress.com/2007/10/16/modular-page-layouts-in-
ruby-on-rails/

– gw

On 10/17/07, Colin S. [email protected] wrote:

What do I do for the “static” files on the site. For every site you
build don’t you have an “About” a “Contact” and “Help” page? Things
right off the root? Right now I have them in the Application directory
and a route points ‘/:action’ to :controller => Application (or
something like that, I’m home now instead of in my office).

I think it’s a good idea to use a single controller for all these, but
don’t use ‘application’, since that’s a base class for your other
controllers. Call it ‘static’ or something.

You can use caching on these pages if they are truly static.

Also, use named routes instead of a catch-all route.

map.about ‘/about’, :controller => ‘static’, :action => ‘about’
map.help ‘/help’, :controller => ‘static’, :action => ‘help’

Then in your view you can write:

<%= link_to ‘About Us’, about_url %>

Makes it real easy to reorganize your URL’s without having to track
down all your link_to’s

I want them to all have the layout from the rest of the site,
obviously.

If your layout is in layouts/application.rhtml, you don’t have to do
anything. Otherwise, you need to specify the layout in your
StaticController.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs