Rails: Hello World / HelloWorld
Note, I was developing on Windows at the time of this post.
Assuming that Ruby and Rails are already installed...Go to the appropriate top level directory [where you want to create your new application]. For me, c:\develop\rubysrc.
rails helloworld
cd helloworld
ruby script\generate controller helloworld
- You can either:
- Use the controller DIRECTLY...
class HelloController < ApplicationController def index render_text << EOF <html> <head> <title>Rails HelloWorld from Controller</title> </head> <body> HelloWorld from Controller </body> </html> EOF end end
- Use a view... Create a file called index.rhtml in app/views/helloworld, containing "Hello World"
<html> <head> <title>Rails HelloWorld from View</title> </head> <body> HelloWorld from View </body> </html>
ruby script\server
- Navigate to http://localhost:3000/helloworld in your browser and be greeted with your friendly application: "Hello World"
2 comments:
Linux requires a forward slash:
ruby script/generate controller helloworld
i am not able to run this application on server.
it is showing "we are sorry something went wrong error".
what could be the problem?
Post a Comment