Ruby on Rails For .Net Programmers
Upcoming SlideShare
Loading in...5
×
 

Ruby on Rails For .Net Programmers

on

  • 6,438 views

An introduction to Ruby on Rails for .NET programmers

An introduction to Ruby on Rails for .NET programmers

Statistics

Views

Total Views
6,438
Views on SlideShare
6,436
Embed Views
2

Actions

Likes
0
Downloads
227
Comments
0

1 Embed 2

http://www.slideshare.net 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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 For .Net Programmers Ruby on Rails For .Net Programmers Presentation Transcript

  • me http://shinydevelopment.com
  • Hype
  • “Ruby on Rails is astounding. Using it is like watching a kung-fu movie, where a dozen bad-ass frameworks prepare to beat up the little newcomer only to be handed their asses in a variety of imaginative ways.” Nathan Torkington
  • “Powerful web applications that formerly might have taken weeks or months to develop can be produced in a matter of days.” Tim O'Reilly
  • What is Ruby on Rails?
  • Ruby Language C# or VB.NET on Rails Framework ASP.NET
  • Ruby
  • Ruby is Object Oriented
  • > 2.next => 3 > “Hello”.reverse => “olleH” > 2.class => Fixnum > 2.class.class => Class
  • > 2.class => Fixnum > 2.class.superclass => Integer > 2.class.superclass.superclass => Numeric > 2.class.superclass.superclass.superclass => Object
  • Ruby is Readable
  • > 5.times { print quot;Hello quot; } Hello Hello Hello Hello Hello > print “Stuff” unless x.nil? => Stuff > [3, 5, 78, 2, 43].sort.reverse => [78, 43, 5, 3, 2] > 2.weeks.from_now.utc => Wed Dec 27 11:25:06 UTC 2006
  • > [1, 2].empty? => false > x.nil? => true
  • > arr = [5, 4, 3] > arr.sort => [3, 4, 5] # arr is still [5, 4, 3] > arr.sort! => [3, 4, 5] # arr is now [3, 4, 5]
  • Ruby is Dynamic
  • > Linguistics::use(:en) > quot;runsquot;.en.present_participle => quot;runningquot; > 5.en.ordinal => quot;5thquot; > quot;cowquot;.en.quantify(1005) => quot;thousands of cowsquot;
  • > animals = %w{dog cow ox chicken goose goat cow dog rooster llama pig goat dog cat cat dog cow goat goose goose ox alpaca} > puts quot;The farm has quot; + animals.en.conjunction => “The farm has four dogs, three cows, three geese, three goats, two oxen, two cats, a chicken, a rooster, a llama, a pig, and an alpaca”
  • class ReverseString def method_missing(method_name) return method_name.to_s.reverse end end > s = ReverseString.new > s.Hello_World => “dlroW_olleH”
  • Rails
  • “Ruby on Rails is an opinionated framework for developing web applications”
  • Convention over Configuration
  • Model Controller View
  • ActiveRecord ActionPack Model View & Controller ActiveSupport JavaScript Libraries Prototype & Script.aculo.us ActionMailer ActionWebService
  • Convention over Configuration
  • Table Class groups Group people Person string.pluralize ABC_usrdetails User table_name_prefix “ABC_” set_table_name “usrdetails”
  • Dynamic Scaffolding and Validations demo
  • Magic?
  • scaffold :customer
  • Ruby is Dynamic
  • Hey, have you seen my new Rails app? I can imagine! *sigh*
  • script / generate
  • More Magic?
  • Routing
  • URL http://localhost:3000/customer/show/2 Routes.rb map.connect ':controller/:action/:id'
  • ActiveRecord
  • “The essence of an Active Record is a domain model in which the classes match very closely the record structure of an underlying database. Each active record is responsible for saving and loading to the database and also for any domain logic that acts on the database” Martin Fowler
  • ActiveRecord ActionPack Model View & Controller MySQL PostgreSQL ActiveSupport JavaScript Libraries MS SQL - ADO Prototype & Script.aculo.us MS SQL - ODBC Oracle ActionMailer ActionWebService SQLite DB2
  • class Customer < ActiveRecord::Base end >> Customer.column_names => [quot;idquot;, quot;namequot;, quot;emailquot;, quot;notesquot;] >> Customer.columns_hash[quot;idquot;] => default=nil, text=false, null=false, sql_type=quot;int(11)quot;, primary=true, name=quot;idquot;, type=:integer, number=true
  • class Customer < ActiveRecord::Base end Customer.find(:all) Customer.find(1) Customer.find_by_email(‘bill@example.com’) Customer.find_by_email_or_name( ‘bill@example.com’, ‘Ben’)
  • class Customer < ActiveRecord::Base end Customer.new do |c| c.email = ‘bill@example.com’ c.name = ‘Bill’ c.save end Customer.delete(1)
  • ActiveRecord Relationships
  • Describe the relationship “A customer has many orders and an order belongs to a customer.”
  • has_many belongs_to
  • Database Relationships demo
  • More Magic?
  • Ruby is Dynamic
  • Orders id Customers customer_id id item name email quantity notes unit_price
  • customer = Customer.find(params[:id]) customer.orders.create(params[:order])
  • Migrations demo
  • Capistrano
  • What next?
  • Try Ruby http://tryruby.hobix.com
  • Instant Rails http://instantrails.rubyforge.org
  • Locomotive http://locomotive.raaum.org/
  • SubSonic http://www.codeplex.com/Wiki/View.aspx? ProjectName=actionpackext Castle Project http://www.castleproject.org/
  • IronRuby
  • Newcastle Ruby on Rails User Group
  • Thank You dave.verwer@shinydevelopment.com