WHY RUBY ON RAILS?
Many platforms are
available for Web development including Microsoft’s .NET, Java 2 Enterprise
Edition, and PHP. Why, then, is there so much interest in a new platform using
a relatively unfamiliar language?
By its design, Ruby
on Rails (RoR) lets you develop Web applications very quickly. It does this by
adhering to conventions rather than forcing you to make all of your
configuration decisions upfront. As a result, RoR lets you develop running
applications in a surprisingly short length of time. Once you install Ruby and
its various required packages, you can create a minimal Web application by
running less than a half-dozen commands and editing one file (database.yml).
RoR includes code generators or libraries that address many of the most common
Web development tasks. The Ruby language has the object-oriented capabilities
of a language like Java, yet you can also use it to create simple scripts. The
language’s range of capabilities increases your ability to create applications
without having to resort to numerous divergent technologies.
DEFINITIONS
What is Ruby?
Ruby is an object-oriented interpreted scripting language created by Yukihiro
Matsumoto. Since the mid-1990s, it has grown in popularity in Japan and has
gained recent attention as the language behind the Rails framework. You can use
the language for a striking variety of functions—from basic scripting to
creating Windows applications to developing Web applications. You can start
using Rails without extensive knowledge of the language; the Rails framework
generates the fundamental classes needed for the Web application and uses
reflection to perform object-relational mapping to the database.
What is Rails?
Rails is a Web application and persistence framework created by David
Heinemeier Hansson. It includes the infrastructure you need to create
database-backed Web applications that use the Model-View-Control (MVC) pattern.
Rails has gained attention as a development framework that lets you rapidly
create full-featured database-backed Web applications.
What is the Model-View-Controller Pattern (MVC)?
The MVC design
pattern is used to separate the following concerns of an application:
Model:
|
Application data, including validation rules
|
View:
|
The way data is presented to the end user
|
Controller:
|
The way a user manipulates the data within the model
|
This pattern has become popular for Web application development, but it
has existed for much longer. Implementations of the pattern have been refined
over time and products have been developed to implement it as a framework. You
can use Java projects such as Struts and Hibernate to develop applications that
leverage the MVC architecture.
In the Rails framework, Active Record deals with Model concerns. It
maps database tables to Ruby objects and provides many other features,
including a way to easily access data, represent and traverse relationships
between tables, validate data, and get data summaries. It also lets you use
straight SQL when desired.
The Action Controller coordinates interactions between the View and
Model layers (letting users change data through the Web). It routes all requests
sent to the Web application, provides a filtering mechanism, Web session
access, and other features.
The Action View deals with what’s actually displayed to the user
(generally in the Web browser). Files that contain HTML and Ruby code are
appended with an .rhtml extension. Helper classes are also available to provide
data formatting.
What is Ruby Gems?
Ruby Gems (or simply gems) is the Ruby packaging system used to package
Rails components. It provides a standard format for distributing Ruby programs
and libraries as well as a tool for managing package installation.
What is OCI8?
The Ruby/Oracle Call Interface (OCI8) is a database driver for
Ruby/DBI. RubyDBI provides a database-independent interface for Ruby. You
install OCI8 to provide a Ruby interface to the underlying Oracle client
software. It’s somewhat analogous to ODBC or JDBC.
Rails Installation on Windows
Follow the steps given below
for installing Ruby on Rails.
Check Ruby Version
First, check if you already have Ruby installed. Open the command prompt and type ruby -v. If Ruby responds, and if it shows a version number at or above 2.2.3, then type gem --version. If you don't get an error, skip Install Ruby step. Otherwise, we'll install a fresh Ruby.Install Ruby
If Ruby is not installed, then
download an installation package http://rubyinstaller.org/downloads/archives . Follow
the download link, and run the
resulting installer. This is an exe file rubyinstaller-2.2.3.x.exe and will be
installed in a single click. It's a very small package, and you'll get Ruby
Gems as well along with this package. Please check the Release Notes for more detail .And also download development kit and
extract to same folder.
Install Rails
Install Rails − With Ruby gems loaded, you can install all of Rails and
its dependencies using the following command through the command line
C:\>gem install rails
Note − the above command may take some time to install all
dependencies. Make sure you are connected to the internet while installing gems
dependencies.
Check Rails Version
Use the following command to
check the rails version.
C:\>rails -v
Congratulations! You are now on Rails over Windows.
Congratulations! You are now on Rails over Windows.
Note: - Development kit after downloading extracted files placed
into Ruby folder
DevKit Overview
The DevKit is a toolkit that
makes it easy to build and use native C/C++ extensions such as Rediscount and Red
Cloth for Ruby on Windows.
Simply
download, double-click, choose an installation directory, run the Ruby install
helper script, possibly tweak a
config.yml
file for your
system specifics, and you’re ready to start using native Ruby extensions.Quick Start
Download
it, run it to extract it somewhere (permanent).
Then cd to it, run ruby
dk.rb init
and ruby
dk.rb install
to bind it to ruby installations in your path.Test Installation
Confirm your Ruby environment is correctly using the DevKit by
running.
JSON should install correctly and you should see
C:\>gem
install json --platform=ruby
JSON should install correctly and you should see
with native extensions
in the screen messages. Keeping Rails Up-to-Date
Assuming you have installed
Rails using Ruby Gems, keeping it up-to-date is relatively easy. We can use the
same command in both Windows and Linux platform. Use the following command
C:\> gem update rails
This will automatically update your Rails installation. The next time you restart your application, it will pick up this latest version of Rails. While using this command, make sure you are connected to the internet.
This will automatically update your Rails installation. The next time you restart your application, it will pick up this latest version of Rails. While using this command, make sure you are connected to the internet.
Installation Verification
You can verify if everything
is set up according to your requirements or not. Use the following command to
create a demo project.
C:\>rails new demo
It will generate a demo rail project; we will discuss about it later. Currently we have to check if the environment is set up or not. Next, use the following command to run WE Brick web server on your machine.
It will generate a demo rail project; we will discuss about it later. Currently we have to check if the environment is set up or not. Next, use the following command to run WE Brick web server on your machine.
C:\>cd demo
C:\> rails server
It will generate auto-code to start the server
C:\> rails server
It will generate auto-code to start the server
Now
open your browser and type the following
http://localhost:3000
It should display a message, something like, "Welcome aboard" or "Congratulations".
It should display a message, something like, "Welcome aboard" or "Congratulations".
No comments:
Post a Comment