Simple introduction about what is Ruby on Rails

I begin to learn ruby on rails since begin of this August. I found out that ruby on rails is awesome, it speed up all my works and make it simple to maintain. So, I wrote this article to introduce about how awesome rails is.
Back to our topic, what is ruby on rails? Web application development framework with ruby language. For more details, you can do some searching on what is ruby on rails, there are many sources you can found on internet.

Installation

It is always easier to be understood by running up the things.
To install rails on your windows or mac PC. There is a quick way to install it by download rails installer and install it.
To install rails on linux os such as ubuntu, debian might needs a little bit more works then windows and mac. There are sources on internet, check it out.

To begin a new project

Before getting start to develop a new web application. You need to setup database, directory of your new project, .htaccess to control the traffic. Maybe you will spent almost half an hours to one hours to setup all those things. But …
Rails, will do it automatically for you.
By typing a few commands for it, rails will do it for you. Here’s the commands.

rails new MyProject
cd MyProject
rails generate model Item name:string price:integer description:text
rails generate controller items index new create show edit update destroy
rake db:migrate
rails server

On first command, create new project and name it “NewProject”. Second command create table name item and columns of name, price and description. Third command create directory for html file, ruby file and routes. Fourth command to startup database and last command to startup the server.

Everything will be setup within 1 minutes. It means, you can begin your programming after 1 minutes. Cool right!

Go to http://localhost:3000 and you will see the welcome message of rails.

 rails2

To check with the project generated, go to http://localhost:3000/items

The page is blank. This is because all you have generated is database, system and routes. There will nothing to show unless html code is written.

Scaffold

A powerful tool that prepared by rails called Scaffold. Scaffold will generate everything including database, simple system code, traffic, html layout code. It means, you can begin to coding from half way instead of blank file.

How to use it? By a few simple command

First create a new project. In this case, named NewProject

rails new NewProject

Then, generate scaffold with following command and startup server.

rails generate scaffold item name:string price:integer description:text
rake db:migrate
rails server

Here’s the result generated by scaffold. Check it out

 rails1

Instead of blank project, scaffold will generate a template for us to make a quick way to start.

End

It is the end of the article, do you think that ruby on rails is awesome?

Advertisements

Install ruby on rails for Aptana Studio 3 on Windows

I spent almost half of my day to install ruby on rails on my Windows PC. After a long fighting on installing, I found an EASY way for windows. Could be said as DAMN EASY.

What you need to do is download the latest version from Rails installer site and run it. Don’t need to download Ruby Installer, as it is included inside Rails installer. What you need to do is waiting until it’s done.

After installed, you can test it by open command prompt and go to whatever testing directory and type

rails new TestApps
cd TestApps
rails server

Then, open browser and go to http://localhost:3000 .If you are able to see the page. Congratulation, you are done with ruby on rails install.

Last things is to download Aptana Studio 3.

Caution here, make sure you install rails first instead of Aptana studio. Otherwise, you have to configure the path for rails on Aptana studio.

If you received error “Unable to find ‘rdebug-ide’ binary script. May need to install ‘ruby-debug-ide’ gem, or may need to add your gem executable directory to your PATH”, when debug ruby in Aptana studio.

Install ruby-debug-ide by following command

gem install ruby-debug-ide

Then, restart your Aptana studio. You should be able to debug ruby file.

Okay! Hope you are already in coding. Thank you for reading.