• Save
Rails v3.2 Basic Introduction
Upcoming SlideShare
Loading in...5
×
 

Rails v3.2 Basic Introduction

on

  • 305 views

 

Statistics

Views

Total Views
305
Views on SlideShare
305
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Rails v3.2 Basic Introduction Rails v3.2 Basic Introduction Presentation Transcript

  • 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 37signals. • Hansson first released Rails as open source in July 2004. • Rails 4.0 Final version released.
  • 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.
  • MVC - Rails Architecture
  • 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.
  • 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.
  • 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.
  • 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.
  • Create a new rails application $ > rails new blog
  • ROR Languages used … Largest sites running in Ruby on Rails  Twitter  Github  Yammer  Scribd  Groupon  Shopify  Basecamp
  • 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
  • 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” }
  • 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
  • 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
  • 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
  • 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")
  • 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)
  • Update b = Blog.find(3) b.title= “Web development" b.Save b = Blog.find(2) b.update_attributes( :title => "Web development", :tags => “web" ) (or)
  • 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 Docs • http://railsapi.com/ and http://apidock.com/rails • Rails 3 Free Screencasts • http://railscasts.com/
  • Thank You !!