Video demonstration of ruby on rails application creation:
One of the many advantages of rails is that it immediately gets you from zero to a functional application. To get started lets create a directory for the rails project called “railsproject”.
Now open the ruby command prompt and navigate to the directory that we just created. Run the rails new command to make your first rails application. Let us call our first rails application as “first”. The rails new command is a program that creates a skeleton rails application. It creates a standard file and directory structure that makes it easier than ever to organize and deploy files. All the rails application have a common file and directory structure making it easy to understand someone else’s code.
rails new first
After the file creation is done rails automatically runs the bundle install command which we will discuss later in this article. Upon successful execution of the rails new command, it will display the message “Your bundle is complete!”
Now lets have a quick look into the files and directories that have just been created. I use Aptana studio, an IDE for windows users of Rails.
Let’s learn more about the files that have been created.
- app – This contains the Core application code including the models, views, controllers and helpers. The model, view and controller are very important parts of a rails architecture which we would learn in-depth in the later articles
- script/rails -A script to generate code and start the local server
- vendor – This contains third party code such as plugins and gems
- Gemfile – This file contains the gem requirements of the application
The bundle install or the bundler command which we had seen in the beginning of this article installs the gems from the Gemfile. The bundler looks for the gems that needs to be installed from this file. Thus the Gemfil should contain the gems needed by your application.
source 'https://rubygems.org' gem 'rails', '3.2.8' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' # To use Jbuilder templates for JSON # gem 'jbuilder' # Use unicorn as the app server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'debugger'