#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    73
    Rep Power
    10

    Embed Ruby On Rails


    Okay, so I first consulted google and did not really find my answer.

    In php, to call my code I imbed it in <?php ?> tags. How do you do this for Ruby? I tried looking up examples, but all I found was raw code.
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2007
    Posts
    1,940
    Rep Power
    3117
    Here is a quick example:

    <% for column in Contact.content_columns %>
    <td><%=h contact.send(column.name) %></td>
    <% end %>


    Source of example:
    http://www-128.ibm.com/developerworks/linux/library/l-rubyrails/
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    73
    Rep Power
    10
    Oooh, okay, I get it, thanx a lot
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    73
    Rep Power
    10
    Sorry to double post..

    When I have my html document, and I am uploading to hosting that offers ruby on rails.
    Code:
    <html>
    <body>
    <% print "text" %>
    </body>
    </html>
    outputs a very raw text string that literally says <% print "text" %>

    I am trying to find guides, but they all seem to walk through what looks like installation of RoR or something. All I know is I want to simply use the code in the website for simple tasks, not create and interface with databases, which all the guides I find seem to want to show me. The guides I find also look like the code is being preformed from a console, which I am not interested in.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2007
    Posts
    1
    Rep Power
    0
    Hi, the majority of web based Ruby development is done using a framework called Ruby on Rails - or RoR. Rails is a plugin for Ruby. While Ruby has basic CGI stuff, RoR gives you a much better interface for building dynamic websites. Your host will have support for RoR built in, probably. It is RoR that alows you to do <%="hello"%> in your HTML. With RoR, you usually create your project offline (it includes a no-install-required web server), so you can build and test offline, then upload your project to the server to go live. In the long run, RoR will offer you *immense benifits* over trying to do HTML with Ruby. I suggest you look at a couple of RoR tutorials. RoR essentially gives you what PHP gives you, but SO much more.

IMN logo majestic logo threadwatch logo seochat tools logo