Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Sep 2009
    Posts
    167
    Thanks
    15
    Thanked 1 Time in 1 Post

    how do you create a simple web page with ruby?

    Hello,

    I have webhosting that has Ruby/Ruby on Rails.

    I know how to set up html web sites. I started learning php, and it's really easy to create a php web page. You just name the file extension .php, and then you intersperse any php code you want in the html with <?php .... ?>. You throw the page up on the web, and it works exactly like you think it would.

    But I have *no idea* how to set up a simple "hello world" web page in ruby. Here's a simple web page. I thought you would just name it with .rb or .rhtml and then upload it to your web hosting server and it would work:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>it would be so great if this ruby page worked</title>
    </head>
    <body>
    <%= puts "Hello World!" %>
    </body>
    </html>

    But it doesn't work:
    1) If I try the file on the hosting server with a .rb extension, it tries to "open" the file like it's downloading a pdf file or something like that.
    2) If I try to use an .rhtml extension, it doesn't work. It echoes the plain text code to the screen, but nothing renders.
    3) If I try using .html as the extension, the page will load, but the ruby code I'm trying to run gets echoed to the screen as a string literal, so the screen outputs <%= puts "Hello World!" %> instead of Hello World!

    So since I already have Ruby and Ruby on Rails in a box ready to go on the webhosting server, what do I do? I thought Ruby was built for the web. But it seems impossible to get a simple web page to render, even on a professional webhosting server that has Ruby/ROR fully installed as part of the package.

    Thanks for any ideas here.

  • #2
    New Coder
    Join Date
    Jan 2012
    Posts
    49
    Thanks
    13
    Thanked 0 Times in 0 Posts
    Okay firstly you need to gain a better understanding of what ruby is. Try this out http://fuelyourcoding.com/creating-y...-from-scratch/http://fuelyourcoding.com/creating-y...-from-scratch/

  • #3
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    I started learning RoR 2 weeks ago. It's been challenging, but it's worth it i think. My suggestion to you is to start from all over from scratch and really understand how RoR works inside out.

    Here is a list of the resources I am using:

    - PeepCode videos ****Excellent content, and CHEAP $12/vid ****
    -Rubyonrails.org *great resource site*
    -Code School
    -Ruby Screencasts **Free&Paid***
    -Agile Web Development with Rails -3rd Edition- Free PDF download
    - Stanford/MIT CSC video classes Free
    -The KHAN Academy.

    I hope this will help you.... Don't get frustrated at the beginning like I did

    Cheers

  • #4
    New Coder
    Join Date
    Nov 2011
    Location
    Austin, Texas, USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by lartisse View Post
    Hi
    Here is a list of the resources I am using:

    - PeepCode videos ****Excellent content, and CHEAP $12/vid ****
    -Rubyonrails.org *great resource site*
    -Code School
    -Ruby Screencasts **Free&Paid***
    -Agile Web Development with Rails -3rd Edition- Free PDF download
    - Stanford/MIT CSC video classes Free
    -The KHAN Academy.

    I hope this will help you.... Don't get frustrated at the beginning like I did

    Cheers
    Whoa, awesome list! I'm using Lynda.com and Code Academy. Thanks for that.

  • #5
    Regular Coder
    Join Date
    May 2012
    Location
    USA
    Posts
    102
    Thanks
    0
    Thanked 7 Times in 7 Posts
    For creating a web page with ruby, first you need to understand about Model-view-controller architecture as it is the base for most web frameworks, including Ruby on Rails. You can pick up the book "Agile Web Development with Rails" for getting a detail explanation about that.


  •  

    Posting Permissions

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