Go Back   CodingForums.com > :: Server side development > Ruby & Ruby On Rails

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-30-2011, 05:55 AM   PM User | #1
code beginner
Regular Coder

 
Join Date: Sep 2009
Posts: 165
Thanks: 15
Thanked 1 Time in 1 Post
code beginner is an unknown quantity at this point
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.
code beginner is offline   Reply With Quote
Old 03-15-2012, 12:10 AM   PM User | #2
stephen_
New Coder

 
Join Date: Jan 2012
Posts: 49
Thanks: 13
Thanked 0 Times in 0 Posts
stephen_ is an unknown quantity at this point
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/
stephen_ is offline   Reply With Quote
Old 03-15-2012, 07:32 PM   PM User | #3
lartisse
New to the CF scene

 
Join Date: Mar 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
lartisse is an unknown quantity at this point
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
lartisse is offline   Reply With Quote
Old 12-04-2012, 05:36 PM   PM User | #4
thebigkick
New Coder

 
Join Date: Nov 2011
Location: Austin, Texas, USA
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
thebigkick is an unknown quantity at this point
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.
thebigkick is offline   Reply With Quote
Old 03-25-2013, 01:33 PM   PM User | #5
annaharris
New Coder

 
Join Date: May 2012
Location: USA
Posts: 83
Thanks: 0
Thanked 4 Times in 4 Posts
annaharris is an unknown quantity at this point
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.
annaharris is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:52 AM.


Advertisement
Log in to turn off these ads.