First test with Ruby on Rails

For this example, we follow the video : http://vimeo.com/43823464

Once Rails and Ruby are installed, choose a directory as a workspace. Go there with your terminal. Now, create the application

rails new blog

The “skeleton” of the application is created. Enter in the root directory, and launch the server

cd blog/

rails server

You can now see the result in your web browser at http://localhost:3000

Since the RubyInstaller install Git, we are gonna use it. So, we have to initialize it for our project, and add all this new file in it.

git init

git add .

git commit -m "Initial commit"

 

Now, we are gonna modified the home page (html) of our application to avoid the Ruby default page

git rm public/index.html

Then we generate the controller for the welcome page.

rails generate controller welcome index

If you are gonna see in app/controllers/welcome_controller.rb, you will find the index action (action executed when you acces to the route localhost:3000/welcome/index/ ). The html page is stored in app/views/welcome/index.html.erb

To make this page the main one, open config/routes.rb and uncomment the line root :to => 'welcome#index'.

Don’t forget to save the modifications with Git

git add .

git commit -m "Added welcome controller"

 

The purpose here was just to get familiar with Rails and Git. The application we created is stupid, but we are gonna improve it !