SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding static pages to a Rails project

    Hi Folks,

    I'm trying to figure out the best way to add pages that will not change to a Rails project. For instance, about us, contact us, etc etc.

    So basically, what I want the URL to look like would be: http://www.abcdefg123.com/about

    Sorry for the total noob question!

  2. #2
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can put static content in the public folder. So the file public/about.html will appear as http://www.abcdefg123.com/about.html.

    You could also consider replacing index.html with your own custom home page. The content of this file will appear when you enter http://www.abcdefg123.com

    The advantage of a static home page is that it will be very fast to load. The disadvantage is that ... well ... it's static. That means modifying it requires alteration of the code. So personally, I'd limit use of static pages to a minimum. Even contact pages change!

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you! Sometimes I miss the forest for the trees, and this is definitely one of those cases. lol

    Just tried it out and it works perfectly under the public folder...and I will definitely keep in mind the potential for things to change and when to use/not use it.

    By the way, is using public/index.html as a default homepage common practice to save on load times/database access?

  4. #4
    l 0 l silver trophybronze trophy lo0ol's Avatar
    Join Date
    Aug 2002
    Location
    Palo Alto
    Posts
    5,329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I usually don't use /public/index.html in that way, primarily because I usually want to use the database on the front page. I sometimes stick these static pages in their own controller (like a "main" controller, for example) just so I can keep organized and to use layouts, partials, and other aspects that the rest of my app uses.

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lo0ol View Post
    so I can keep organized and to use layouts, partials, and other aspects that the rest of my app uses.
    I realized...shortly after posting my reply...that I lost access to the all that good stuff.

    I'm definitely going to be needing the layout for my static pages, so it looks like a controller is the way to go for me.

  6. #6
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use Rails' caching capabilities! That way you get the good stuff and the speed


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •