![]() |
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. |
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/
|
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 |
Quote:
|
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.
|
| All times are GMT +1. The time now is 08:55 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.