Your SlideShare is downloading. ×
Ruby On Rails
Web Application Framework
D. Prabu
Senior Technical Consultant,
Spritle Software PVT LTD,
Chennai.
History
• David Heinemeier Hansson extracted
Ruby on Rails from his work
on BaseCamp, a project management
tool by 37signa...
WAF
• A web application framework (WAF) is a software
framework that is designed to support the development
of dynamic web...
MVC - Rails Architecture
Model (Active Record)
• It is responsible for representing business
data and logic
• It takes how to Write and Read from t...
View (Layout)
• To generate an output representation to the
user.
• It is composed of “templates”, that are
responsible fo...
Controller
• It is responsible for handling incoming
HTTP requests and providing a suitable
response.
• Rails controllers ...
Rails Strengths
It has grown when it comes to the number of
features allowing developers to achieve more in less time.
• C...
Create a new rails application
$ > rails new blog
ROR Languages used …
Largest sites running in Ruby on Rails
 Twitter
 Github
 Yammer
 Scribd
 Groupon
 Shopify
 Bas...
Blogs
id title tags
1. Benefits Of Ruby RUBY
2. Mobile Frameworks MOBILE
3. Getting Started with Personal Web Pages WEB
4....
Blogs
id title tags
1. Benefits Of Ruby RUBY
2. Mobile Frameworks MOBILE
3. Getting Started with Personal Web Pages WEB
4....
result = { :title => “Getting Started with Personal Web Pages” ,
:tags=>” WEB” }
puts result[:title] => “Getting Started w...
id title tags
1. Benefits Of Ruby RUBY
2. Mobile Frameworks MOBILE
3. Getting Started with Personal
Web Pages
WEB
4. Respo...
CRUD
Create
Read
Update
Delete
b = Blog.new
b.title= “Ruby Source"
b.save
b = Blog.find(3)
b = Blog.find(3)
b.title= “Web ...
Create
b = Blog.new
b.title= “Ruby Source“
b.tags = “ruby”
b.save
Alternate Syntax
b = Blog.new(:title=> “Ruby Source", :t...
Read
Blog.find(2) # Returns a single item
Blog.find(3, 4, 5)
Blog.first
# Returns an array
# Returns the first blog
Blog.o...
Update
b = Blog.find(3)
b.title= “Web development"
b.Save
b = Blog.find(2)
b.update_attributes( :title => "Web development...
Delete
b = Blog.find(2)
b.destroy
Blog.find(2).destroy
Blog.destroy_all
(or)
(or)
Web Links
• RailsTutorial
• http://ruby.railstutorial.org/
• Rails Guides
• http://guides.rubyonrails.org/
• Rails API Doc...
Thank You !!
Rails v3.2 Basic Introduction
Rails v3.2 Basic Introduction
Upcoming SlideShare
Loading in...5
×

Rails v3.2 Basic Introduction

182

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
182
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Rails v3.2 Basic Introduction"

  1. 1. Ruby On Rails Web Application Framework D. Prabu Senior Technical Consultant, Spritle Software PVT LTD, Chennai.
  2. 2. History • David Heinemeier Hansson extracted Ruby on Rails from his work on BaseCamp, a project management tool by 37signals. • Hansson first released Rails as open source in July 2004. • Rails 4.0 Final version released.
  3. 3. WAF • A web application framework (WAF) is a software framework that is designed to support the development of dynamic websites, web applications, web services and web resources. • Rails is a web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.
  4. 4. MVC - Rails Architecture
  5. 5. Model (Active Record) • It is responsible for representing business data and logic • It takes how to Write and Read from the database. • ORM, is a technique that connects the rich objects of an application to tables in DB.
  6. 6. View (Layout) • To generate an output representation to the user. • It is composed of “templates”, that are responsible for providing appropriate representations of your application’s resource. • Templates can come in a variety of formats, but most view templates are HTML with embedded Ruby code.
  7. 7. Controller • It is responsible for handling incoming HTTP requests and providing a suitable response. • Rails controllers can generate HTML, XML, JSON, PDFs, and more. In Rails, the Controller and View layers are handled together by Action Pack.
  8. 8. Rails Strengths It has grown when it comes to the number of features allowing developers to achieve more in less time. • Convention over configuration  Most web development frameworks for .NET or Java force you to write pages of configuration code. Rails doesn't need much configuration.  Developers to focus on “what they are doing ” instead of on “how they are doing it” the approach is meant to boost their productivity. • DRY concept  Keep your business logic in one place.
  9. 9. Create a new rails application $ > rails new blog
  10. 10. ROR Languages used … Largest sites running in Ruby on Rails  Twitter  Github  Yammer  Scribd  Groupon  Shopify  Basecamp
  11. 11. Blogs id title tags 1. Benefits Of Ruby RUBY 2. Mobile Frameworks MOBILE 3. Getting Started with Personal Web Pages WEB 4. Responsive Web Design CSS 5. Practicing Ruby RUBY Question : Retrieve a hash of the blog title with id = 3
  12. 12. Blogs id title tags 1. Benefits Of Ruby RUBY 2. Mobile Frameworks MOBILE 3. Getting Started with Personal Web Pages WEB 4. Responsive Web Design CSS 5. Practicing Ruby RUBY Question : Retrieve a hash of the blog title with id = 3 Answer : Result = { :title => “Getting Started with Personal Web Pages” , :tags=>” WEB” }
  13. 13. result = { :title => “Getting Started with Personal Web Pages” , :tags=>” WEB” } puts result[:title] => “Getting Started with Personal Web Pages” puts result[:tags] => “WEB” (or) puts result.title => “Getting Started with Personal Web Pages” puts result.tags => “WEB” HASH Series of key value pairs
  14. 14. id title tags 1. Benefits Of Ruby RUBY 2. Mobile Frameworks MOBILE 3. Getting Started with Personal Web Pages WEB 4. Responsive Web Design CSS 5. Practicing Ruby RUBY Blogs b = Blog.find(3)Answer : Question : Retrieve a hash of the blog title with id = 3 puts b[:title] => “Getting Started with Personal Web Pages” puts b[:tags] => “WEB” puts b[:id] => 3 Pluralize
  15. 15. CRUD Create Read Update Delete b = Blog.new b.title= “Ruby Source" b.save b = Blog.find(3) b = Blog.find(3) b.title= “Web development" b.Save b = Blog.find(3) b.destroy
  16. 16. Create b = Blog.new b.title= “Ruby Source“ b.tags = “ruby” b.save Alternate Syntax b = Blog.new(:title=> “Ruby Source", :tags => “ruby") b.save (or) Blog.create(:title => " Ruby Source ", :tags => “ruby")
  17. 17. Read Blog.find(2) # Returns a single item Blog.find(3, 4, 5) Blog.first # Returns an array # Returns the first blog Blog.order(:tags) # All ordered by tags Blog.last # Returns the last blog Blog.all Blog.limit (10) # Returns all the blogs # Only 10 blogs Blog.where(:tags =>“ruby”) # Only blogs by ruby Blog.where(:tags => “ruby").order(:tags).limit(10)
  18. 18. Update b = Blog.find(3) b.title= “Web development" b.Save b = Blog.find(2) b.update_attributes( :title => "Web development", :tags => “web" ) (or)
  19. 19. Delete b = Blog.find(2) b.destroy Blog.find(2).destroy Blog.destroy_all (or) (or)
  20. 20. Web Links • RailsTutorial • http://ruby.railstutorial.org/ • Rails Guides • http://guides.rubyonrails.org/ • Rails API Docs • http://railsapi.com/ and http://apidock.com/rails • Rails 3 Free Screencasts • http://railscasts.com/
  21. 21. Thank You !!

×