Monday, May 26, 2014

First Ruby on Rails Application.

The first thing you need to do is to make sure you have everything installed on your Linux box.  On my older Ubuntu box this involved running the command:
sudo apt-get install ruby rails sqlite3 libsqlite3-rails 
Then I ran the following commands:
mkdir RubyOnRailsApps
cd RubyOnRailsApps
rails FirstApp
cd FirstApp/
./script/generate controller Say
vi app/controllers/say_controller.rb 
  And make the file look like:  
  class SayController < ApplicationController
    def hello   

    end
  end
vi app/views/say/hello.rhtml
  And make the file look like: 
  
    <html>
     <head>      
       <title> First Ruby On Rails App! </title>    
     </head>    
     <body>      
       Hello World!    
     </body>  
  </html>
Finally, start the server like this:
./script/server 
Then type this into your web browser:
 http://localhost:3000
And you should see the following;




No comments:

Post a Comment