SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is it bad to use RoR for websites?

    I wonder (and i would like to try it the next website job i take) if it is right to use rails to develop a normal static website. I think it would be nice and efficent to use rails facilities to develop even the simplest website 'cause with rails you have at disposal tools and things like template engine, organized files, a datbase to store even staic content and eventually use it to develop a multilanguage site etc.
    What do you think? Would be just a waste of resources for a normal site?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    You could, but I don't see the benefit to using Rails for say a 5-page simple brochure site. In that case I'd probably just do a real static HTML site, maybe using a PHP script for a contact form or something.

  3. #3
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia View Post
    You could, but I don't see the benefit to using Rails for say a 5-page simple brochure site. In that case I'd probably just do a real static HTML site, maybe using a PHP script for a contact form or something.
    i really need the template engine feature but i think php includes are not enough

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Smarty then?

    All I'm saying is that if it really is a simple site, even a template engine may not be necessary. If it's more complex then yes it might be something where Rails or PHP can help.

  5. #5
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia View Post
    Smarty then?

    All I'm saying is that if it really is a simple site, even a template engine may not be necessary. If it's more complex then yes it might be something where Rails or PHP can help.
    for me even the simplest static website (five or more pages) need php to at least manage the general layout of the site. If tomorrow my client decide to change a little thing in the layout i don't have to edit five or more pages. But i think php includes are less flexible than layout management of rails and furthermore i need rails and a database for a simple static webpage 'cause if i put my content in a database i can make for example the english versione of the site for my client in a easy way (i'm italian ). Anyway the central point is that i think it will be easier for me as a developer to manage and develop a simple static site with rails but i don't know if it is worth in term of resources.

  6. #6
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Write a Ruby script that generates the website

  7. #7
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fenrir2 View Post
    Write a Ruby script that generates the website
    more on this?

  8. #8
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your site is static, but you want templates. You don't want repeat the layout for every page because that will mean a lot of work if you want to add a navigation link to your layout.

    So you write a Ruby script that reads the content/text from files and puts it in a layout. You can generate the navigation from these files and it's pretty easy to add other languages.

    You can use the usual Rails templates (.rhtml) for this. (look for "erb", "embedded ruby").

  9. #9
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    sheffield
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use caching to reduce the resources used. One of the disadvantages with it is that you'll have to host it on a webserver that supports rails. If you are designing the site for a client then you are also locking them into needing a wenhost that supports rails.

    However, building simple sites in rails does have its advantages, espescially if you are familiar with rails already. I think there is a recipe in rails recipes that talks about using rails for static sites.

    I built a static site with rails and found it really helpful. If you use capistrano then you have a very easy way of updating your site and when your client wants to extend their site, for example add a contact us page etc, you're all set to do it quickly.
    Mongolia Overland - The Greatest Adventure on Earth

  10. #10
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arran View Post
    You can use caching to reduce the resources used. One of the disadvantages with it is that you'll have to host it on a webserver that supports rails. If you are designing the site for a client then you are also locking them into needing a wenhost that supports rails.

    However, building simple sites in rails does have its advantages, espescially if you are familiar with rails already. I think there is a recipe in rails recipes that talks about using rails for static sites.

    I built a static site with rails and found it really helpful. If you use capistrano then you have a very easy way of updating your site and when your client wants to extend their site, for example add a contact us page etc, you're all set to do it quickly.
    so i can try to use rails for my next static (3,4,5 or more pages) website job and i can put the static content in a database and create a Page model for my static pages right?

  11. #11
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think there is a recipe in rails recipes that talks about using rails for static sites.
    yes in that recipe he says to use a controller named for example "pages" with the cache support. So also no model nedded at all.

  12. #12
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think at this stage you want to use the php's HERE DOC feature. Ruby supports it too but PHP can run on just about webserver. Here is a generic version I used doing php sites.

    Code:
    <?php
    
    class pageLayout {
        var $_year;
        var $sid;
        var $title;
        var $client;
        var $content;
        var $page;
        
      
        function pageLayout($sid, $title, $client, $content) {
    	$this->title = $title;
    	$this->sid = $sid;
    	$this->client = $client;
    	$this->content = $content;
    	$this->addHeader();
    	$this->_year = date("Y");
        }
    
        function addHeader() {
    		$this->page .= <<<EOL
    		<html>
    		<head>
    		<title>$this->title</title>
    		<link rel="stylesheet" type="text/css" href="style.css" />
    		</head>
    		<body>
    EOL;
        }
    
        function addContent() {
    	$this->page .= $this->content;
        }
    
        function addFooter() {
            $this->page .= <<<EOF
            <div align="center">&copy; $this->_year $this->client</div>
            </body>
            </html>
    EOF;
        }
    
        function getPage() {
    		$temp = $this->page;
    		$this->addFooter();
    		$page = $this->page;
    		return $page;
        }
    ?>

  13. #13
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not just put that in a template (.php) file and include it? Anyway, Rails uses templates for this.

  14. #14
    SitePoint Zealot mpdesigns's Avatar
    Join Date
    Apr 2004
    Location
    Wisconsin
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia View Post
    Smarty then?

    All I'm saying is that if it really is a simple site, even a template engine may not be necessary. If it's more complex then yes it might be something where Rails or PHP can help.
    Well Rails would just simply give you more ground to expand on where as with php you have to build your own ground and work from there.

    I strongly believe Rails is completely appropriate for small websites. Think about competition, if everybody else is slaving over keeping their (x)html up-to-date, how much more ahead of the game you'll be when all you have to do change a couple things and then commit your changes to the live site?

    I think that in itself is a great benefit of using rails for static websites. You give static content a sprinkle of functionality as well.
    Keep it Symple!

  15. #15
    Web developer Carl's Avatar
    Join Date
    Sep 2003
    Location
    sweden
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you just want Ruby syntax and templating features then use eRuby rather than Rails.

  16. #16
    SitePoint Zealot mpdesigns's Avatar
    Join Date
    Apr 2004
    Location
    Wisconsin
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is eRuby tailored to build production websites?
    Keep it Symple!

  17. #17
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by mpdesigns View Post
    is eRuby tailored to build production websites?
    What do you think RHTML files are? They're just eruby templates.

  18. #18
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oddly enough, I would look at using ERuby, or Camping for you are doing if you want quick results. You could use PHP, it's about the only time when it's useful imo.

    I'm looking at the idea of making a Rails CMS that will generate static website for you where it publishs static HTML files (and images etc). This is different from most other CMS systems because the content generated is truely static and therefore you don't need RoR on the webserver to the site.

    I've been testing this idea for a small local company who make marine fittings. The idea is they can upload photos and product information on a copy of this RoR based publishing system that is able to run locally on their computers using SQLite as the database. Once they have done this, the can publish the site, which basically looks at modified content and exports it to HTML and resizes images, and then uploads them to the webspace using FTP (because their hosting doesn't have RoR support). While I only have a partly working prototype, the system is looking good.

    The reason I went down this route is because my client can also publish the site to a local folder which means they can then write copies of the website to CD when going to trade shows. The other advantage is that I have also got this system to generate PDF versions of their product catalog for them. This is why I've developed such system (as opposed to using eRuby, or camping)

    Anyway, I'm still trying to finish off the project. It's a little pet project I've been working on and I'm keen to find others who might be interested in such tool for similar sites. If you have such interst, please give me a private message, as I'll be intersted in sharing this with any testers (let it be known in the current state you will need some reasonable RoR skills as I need to get round to documenting things and finishing some parts off, like I said this is a prototype system in it's current form). I do plan to release the code open source further down the line, but not for a while.
    http://virtualfunction.net - Rails Web Development
    http://squaremove.co.uk - Rails powered Property Listings


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
  •