Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Ruby on Rails
::The New Gem of Web Development
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Web application framework
Dynamically typed programming language
Create or manage web applications which manipulate relational database from a web-based user interface
Ruby on Rails
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Ruby ??
Pure object-oriented programming language
Everything is an object
Interpreted scripting language
Ruby successfully combines Smalltalk's conceptual elegance, Python's ease of use and learning and Perl's pragmatism.
Ruby originated in Japan in 1993 by Yukihiro “matz” Matsumoto, and has started to become popular worldwide in the past few years as more English language books and documentation have become available.
Ruby is a metaprogramming language.
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
What is Rails?Ruby on Rails or just Rails (RoR)
An open source Ruby framework
Created by David Heinemeier Hansson – DHH Partner
The Rails framework was extracted from real-world web applications.
All layers in Rails are built to work together so you Don’t Repeat Yourself
Everything in Rails (templates to control flow to business logic) is written in Ruby Except for configuration files - YAML
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Rails Strengths – It’s all about Productivity
Metaprogramming techniques Metaprogramming replaces these two primitive techniques
and eliminates their disadvantages. Ruby is one of the best languages for metaprogramming,
and Rails uses this capability well.
Scaffolding which can quickly construct most of the logic and views
needed to do common operations, such as Create, Read, Update and Delete (CRUD).
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Rails Strengths – Write Code not Configuration
Convention over configuration Naming your data model class with the same name as the
corresponding database table ‘id’ as the primary key name
Rails introduces the Active Record framework, which saves objects to the database.
The Rails version of Active Record discovers the columns in a database schema and automatically attaches them to your domain objects using metaprogramming.
This approach to wrapping database tables is simple, elegant, and powerful.
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Rails Strengths – Full-Stack Web Framework
Rails implements the model-view-controller (MVC) architecture. The MVC design pattern separates the component parts of an application
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
For exampleIf there is a class Post, the following code:
a = Post.new a.subject = "Example message" a.body = "This is an example message." a.Save
INSERT INTO posts (subject, body) VALUES ('Example message', 'This is an example message.');
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
b = Post.find(:all, :conditions => ['score > 80'])
is conceptually equivalent to the following SQL command:
SELECT * FROM posts WHERE score > 80;
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Rails Strengths
Three environments: development, testing, and production
Rails embraces test-driven development. Unit testing: testing individual pieces of code Functional testing: testing how individual pieces of
code interact Integration testing: testing the whole system
Database Support: Oracle, DB2, SQL Server, MySQL, PostgreSQL, SQLite
Rails Application Directory Structure
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Hello Rails!
def sayGoodmorning(name)
result = "GoodMorning," + name
return result
end
# Time for tea...
puts sayGoodmorning(“Think ahead")
puts sayGoodmorning(“Think ahead ")
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Hello Rails!
Out put is:
GoodMorning Think ahead
GoodMorning Think ahead
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Rail’s two guiding principles: Less software (Don’t Repeat Yourself - DRY) Convention over Configuration (Write code not
configuration files)
High Productivity and Reduced Development Time
Summary
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Its just like this
Think Ahead | Ph: +91 80 25584238, 25321797 | Fax: +91 80 25321798 www.thinkahead.net
Thank you
Top Related