Ruby On Rails Siddhesh
Upcoming SlideShare
Loading in...5
×
 

Ruby On Rails Siddhesh

on

  • 1,057 views

Introduction to Ruby on Rails

Introduction to Ruby on Rails

Statistics

Views

Total Views
1,057
Slideshare-icon Views on SlideShare
1,037
Embed Views
20

Actions

Likes
0
Downloads
10
Comments
0

3 Embeds 20

http://siddhesh-musings.blogspot.com 17
http://siddhesh-musings.blogspot.in 2
http://www.linkedin.com 1

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

    Ruby On Rails Siddhesh Ruby On Rails Siddhesh Presentation Transcript

    • Ruby On Rails… Siddhesh Bhobe
    • What is Ruby?
      • An OO language!
      • … successfully combines Smalltalk's conceptual elegance, Python's ease of use and learning, and Perl's pragmatism…
      • … originated in Japan in the early 1990s
    • What is Rails?
      • Rails is an open source Ruby framework for developing database-backed web applications
      • Rail's guiding principles:
        • less software and
        • convention over configuration
    • Why the hell do we need another language and another framework???
    • Well… What if you could develop a web application at least ten times faster with Rails?
    • Let’s start with a demo…
    • Demo Steps
      • Install Instant Rails which includes Rails, MySQL and an in-built web server – directory copy, no installation required
      • Create a Rails project
      • Create a database with sample table
      • Generate the model and controller in Rails
      • Provide CRUD functionality for the table on the web
      • IN TEN MINUTES
      • Check http://instantrails.rubyforge.org/tutorial/index.html to try this on your own!
    • The Project Hierarchy – Convention over Configuration
    • Main Modules of a Rails Application
      • The controllers subdirectory is where Rails looks to find controller classes. A controller handles a web request from the user.
      • The views subdirectory holds the display templates to fill in with data from our application, convert to HTML, and return to the user's browser.
      • The models subdirectory holds the classes that model and wrap the data stored in our application's database.
      • The helpers subdirectory holds any helper classes used to assist the model, view, and controller classes.
    • Notes
      • The “scaffold” provides basic CRUD functionality, as well as basic views for the data – this can be overridden by you
      • URLs are simple and straightforward
      • Smartly maps models to table names - Recipe to recipes, Person to people and Country to countries 
    • Overriding Scaffold Methods
      • Define your method (say, for the list functionality) in the controller
    • Overriding Scaffold Methods
      • Provide your own list.rhtml - simply an html file with Ruby code embedded within <% %> and <%= %> tags
    • And We Get..
    • Setting Relationships between Model Objects
      • Class Recipe < ActiveRecord::Base
      • belongs_to :category
      • End
      • Class Category < ActiveRecord::Base
      • has_many :recipes
      • end
    • Use Layouts
      • Provides common header/footer for all pages
      • Actual content goes in place of @content_for_layout
    • And We Get…
    • Hey, but this was too simple an application! Does it do anything serious?
    • Some Real Applications
      • Basecamp is a web-based tool that lets you manage projects (or simply ideas) and quickly create client/project extranets. It lets you and your clients (or just your own internal team) keep your conversations, ideas, schedules, to-do lists, and more in a password-protected central location.
      • http://www.basecamphq.com/
    • Some Real Applications
      • 43 Things is a goal-setting social software web application. It currently has 6,000 registered users and hundreds of thousands of unregistered visitors. 43 Things has 4,500 lines of code that were developed in three months by three full-time developers.
      • http://www.43things.com/
    • Some Real Applications
      • Ta- da Lists is a free online service that implements simple, sharable to-do lists. It features a highly responsive user interface that uses XMLHttpRequest to minimize waiting for the server. Ta-da Lists came from one developer using one week of development time producing 579 lines of code.
      • http://www.tadalist.com/
    • And More..
      • Check out the screencasts at
      • http://www.rubyonrails.org/screencasts
    • Cool Rails Features
      • Caching
        • Page (as HTML), Action (Similar to Page, but applies filters like authentication), Fragment
        • Caches calculations, renderings and database calls
        • Sweeper – cleans the cache based on changes to the model objects
      • Data Validation
      • validates_length_of :category, :within => 1..20
      • Callbacks (like before and after triggers) – very useful for cache sweeping, for example
      • Transactions – save and destroy are already covered
      • Custom Code Generators
    • Ajax on Rails
      • Ajax (Asynchronous JavaScript and XML) works on top of XMLHttpRequest
      • Ajax (through XMLHttpRequest) lets browser-side JavaScript communicate with the web server in the background without requiring the browser to display a new web page
      • Libraries like DWR and Ajax.NET provide high-level services for Ajax that hide browser-specific differences
      • Rails has built-in support for Ajax
    • How it Works in Rails
      • A trigger action occurs. This could be the user clicking on a button or link, the user making changes to the data on a form or in a field, or just a periodic trigger.
      • Data associated with the trigger (a field or an entire form) is sent asynchronously to an action handler on the server via XMLHttpRequest.
      • The server-side action handler takes some action based on the data, and returns an HTML fragment as its response.
      • The client-side JavaScript (created automatically by Rails) receives the HTML fragment and uses it to update a specified part of the current page's HTML, often the content of a <div> tag.
    • A Sample View File
    • The Corresponding Controller
    • And You Get…
    • References
      • Article on which this presentation is based: http://instantrails.rubyforge.org/tutorial/index.html
      • Ruby Homepage:
      • http://www.ruby-lang.org/en/
      • Ruby on Rails Homepage:
      • http://www.rubyonrails.com/
      • Four Days on Rails (great to start with):
      • http://rails.homelinux.org/
      • Ruby on Rails How Tos:
      • http://wiki.rubyonrails.com/rails/pages/Howtos