Ruby on Rails: Building Web Applications Is Fun Again!


Published on

Anthony Eden presentents us for Ruby on Rails.

Published in: Technology, Business
1 Comment
  • I am new to ruby on rails I don't have an idea systax also
    can you give me some sourcess to learn ruby on rails programming
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Ruby on Rails: Building Web Applications Is Fun Again!

  1. 1. Ruby on Rails Building Web Applications Is Fun Again!
  2. 2. What is Ruby on Rails? <ul><li>Web application framework written in Ruby </li></ul><ul><li>Ruby is an Object Oriented scripting language </li></ul><ul><li>Model-view-controller </li></ul><ul><li>Database agnostic </li></ul><ul><li>Open source </li></ul><ul><li>Lots of nice tools, classes and methods to make development easier </li></ul>
  3. 3. The Rails Way <ul><li>DRY (Don’t Repeat Yourself) </li></ul><ul><li>Convention over configuration </li></ul><ul><li>Baked in testing </li></ul><ul><li>Minimal code with maximum effect </li></ul>
  4. 4. <ul><li>Installing Ruby, Gem and Rails </li></ul><ul><li>Install Ruby OCI8 Driver </li></ul><ul><li>Connect using TNSNAMES.ORA </li></ul><ul><li>Connect using InstantClient and a URL </li></ul><ul><li>More information on </li></ul>Getting Started
  5. 5. Rails on Oracle <ul><li>Key generation assumes sequences for each table with the name ${table_name}_seq </li></ul><ul><li>Sequence name can be changed using ActiveRecord::Base.set_sequence_name </li></ul><ul><li>Timezones and sub-second precision not supported </li></ul><ul><li>More info: </li></ul>
  6. 6. Building Your First App <ul><li>Create a new Rails app by typing: rails myapp </li></ul><ul><li>Edit the config/database.yml </li></ul><ul><li>Generate a model using: script/generate model MyModel </li></ul><ul><li>Creating a model creates a class and a migration </li></ul>
  7. 7. ActiveRecord Conventions <ul><li>Naming convention simplifies development and encourages good database design </li></ul><ul><li>Tables are plural, models are singular </li></ul><ul><li>Example: </li></ul><ul><ul><li>Model: LineItem </li></ul></ul><ul><ul><li>Table: line_items </li></ul></ul><ul><li>Handles non-regular pluralization such as Person/people </li></ul><ul><li>Can be overridden, although this complicates things for the developer </li></ul>
  8. 8. Database Migrations <ul><li>Database agnostic means of defining schema </li></ul><ul><li>Lowest-common-denominator approach </li></ul><ul><li>Ruby code with full access to ActiveRecord </li></ul><ul><li>Methods for creating, altering and dropping tables, columns and indexes </li></ul><ul><li>Can execute arbitrary SQL with ‘execute’ method </li></ul>
  9. 9. ActiveRecord Models <ul><li>Object/Relational Mapping </li></ul><ul><li>Model classes extend from ActiveRecord::Base </li></ul><ul><li>ActiveRecord::Base provides: </li></ul><ul><ul><li>Database agnostic record creation, finding, saving and removal </li></ul></ul><ul><ul><li>Data validation methods </li></ul></ul><ul><ul><li>Relationships </li></ul></ul><ul><ul><li>All in an easy to use package </li></ul></ul><ul><li>Rails encourages keeping business logic in the model where it belongs </li></ul><ul><li>AR can be used outside of web applications </li></ul>
  10. 10. Views <ul><li>Responsible for creating part or all of the page displayed in a browser </li></ul><ul><li>By default uses ERb (Embedded Ruby) </li></ul><ul><li>Other views include ‘builders’ for XML documents or RJS templates to generate JavaScript for AJAX driven views </li></ul><ul><li>Includes elegant means for including helper functions for rendering </li></ul><ul><li>Supports partials and components </li></ul>
  11. 11. Controllers <ul><li>Generate controllers with script/generate controller MyController </li></ul><ul><li>Controllers tie the view to the model through actions </li></ul><ul><li>Controllers also have access to “helpers” </li></ul><ul><li>Designed for people-friendly URLs </li></ul><ul><li>Provides caching, session management, query parsing, cookie management, pagination </li></ul>
  12. 12. ActiveRecord Relationships <ul><li>Relationships are through primary keys </li></ul><ul><li>Supported relationship types: </li></ul><ul><ul><li>belongs_to (book belongs to author) </li></ul></ul><ul><ul><li>has_one (book has one publisher) </li></ul></ul><ul><ul><li>has_many (book has many pages) </li></ul></ul><ul><ul><li>has_and_belongs_to_many (book has and belongs to many readers) </li></ul></ul><ul><ul><li>has_many :through (book has many contributors through contributions) </li></ul></ul>
  13. 13. ActiveRecord Validation <ul><li>validates_presence_of </li></ul><ul><li>validates_uniqueness_of </li></ul><ul><li>validates_confirmation_of </li></ul><ul><li>validates_acceptance_of </li></ul><ul><li>validates_associated </li></ul><ul><li>validates_each </li></ul><ul><li>validates_format_of, _length_of </li></ul><ul><li>validates_exclusion_of, _inclusion_of </li></ul>
  14. 14. More ActiveRecord <ul><li>Acts As </li></ul><ul><ul><li>acts_as_list (position) </li></ul></ul><ul><ul><li>acts_as_tree (parent_id) </li></ul></ul><ul><li>Aggregations </li></ul><ul><ul><li>composed_of </li></ul></ul><ul><li>Callbacks </li></ul><ul><ul><li>Full lifecycle </li></ul></ul><ul><ul><li>Before and after validation, creation, saving, destroying </li></ul></ul><ul><li>Calculations </li></ul><ul><ul><li>average, count, maximum, minimum, sum </li></ul></ul>
  15. 15. Just When You Thought You Had Enough ActiveRecord <ul><li>Callback objects </li></ul><ul><li>Observers </li></ul><ul><li>Façade columns </li></ul><ul><li>Object-level transaction management </li></ul><ul><li>Magic column names </li></ul><ul><ul><li>created_on, created_at, updated_on, updated_at auto timestamping and dating </li></ul></ul><ul><ul><li>lock_version and optimistic locking </li></ul></ul><ul><ul><li>type for single table inheritence </li></ul></ul><ul><ul><li>xxx_count counter cache </li></ul></ul>
  16. 16. Other Stuff <ul><li>ActionMailer for sending mail messages </li></ul><ul><li>ActionView helpers </li></ul><ul><ul><li>Form helpers </li></ul></ul><ul><ul><li>Asset tags </li></ul></ul><ul><ul><li>Javascript support (yummy AJAX!) </li></ul></ul><ul><ul><li>Pagination </li></ul></ul><ul><ul><li>Text helpers </li></ul></ul><ul><li>ActionWebService </li></ul><ul><li>Ruby language extensions </li></ul><ul><li>Breakpoint and debugging </li></ul>
  17. 17. Where To Go Next? <ul><li> / </li></ul><ul><li> / </li></ul><ul><li> </li></ul><ul><li>Agile Web Development with Rails </li></ul><ul><li> for Ruby </li></ul><ul><li>Programming Ruby </li></ul><ul><li>IRC, Mailing Lists, Seth Ladd’s brain </li></ul>