1 / 24

RUBY ON RAILS

RUBY ON RAILS. Introduction to Ruby. What is Ruby?. Ruby is: from Japan. Yukihiro “Matz” Matsumoto. Ruby is: a scripting language. “Ruby is simple in appearance, but is very complex inside, just like our human body.” – Matz. Ruby is: Object Oriented.

base
Download Presentation

RUBY ON RAILS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RUBY ON RAILS • Introduction to Ruby

  2. What is Ruby?

  3. Ruby is: from Japan • Yukihiro “Matz” Matsumoto

  4. Ruby is: a scripting language • “Ruby is simple in appearance, but is very complex inside, just like our human body.” – Matz

  5. Ruby is: Object Oriented • “I wanted a scripting language that was more powerful than Perl, and more object-oriented than Python.” • – Matz • 5.times { print "We *love* Ruby -- it's outrageous!" }

  6. Ruby is: Flexible • class Numeric • def plus(x) • self.+(x) • end • end • y =5.plus 6 • # y is now equal to 11

  7. Ruby has:Blocks • search_engines = • %w[Google Yahoo MSN].map do|engine| • "http://www."+ engine.downcase +".com" • end • # search_engines = [‘http://www.google.com’,http://www.yahoo.com’, ‘http://www.msn.com’]

  8. Ruby is:Single Inheritance • class MyArray •   include Enumerable • end

  9. Ruby is:Pretty Easy to Read • var could be a local variable. • @var is an instance variable. • $var is a global variable.

  10. What is Rails?

  11. Rails is: • A Web Application Framework • written in Ruby

  12. What’s the advantage? • Functionality common to many web applications abstracted into a stable, tested code base. • Rails leverages the RubyGem code packaging system to make installing and versioning libraries of code exceedingly easy.

  13. So why is Rails unique? • Convention Over Configuration approach to get you started quickly. • DRY principles and built-in testing to help ensure your code is lasting.

  14. How easy is it, really? • Let’s do an example.

  15. How is it Structured? • Model View Controller • Model=State, View=Response to User, Controller=Logic

  16. How does that show up in Rails? • Model — ActiveRecord • Controller—ActionController • View—ActionView

  17. MVC in Webapps

  18. Model • OO abstraction for RDB • Classes—Tables • Objects—Rows • Queries & Operations—Class Methods • class Client < ActiveRecord::Base • has_one :address • has_one :mailing_address • has_many :orders • end

  19. View • Templates for HTML documents • ERB—Embedded Ruby

  20. Controller • Interface between user, model and view. • This is where you line everything up.

  21. Let’s go back to the example

  22. Assignment • “Seems really pricey for a relatively simple software like this. Someone write an opensource alternative? it looks like something that can be thrown together in a weekend.” • — ktharavaad writing about Stack Overflow @ news.ycombinator.com

  23. Rewrite Stack Overflow • Requirements: Questions, Responses, Users, Voting • Go further if you feel ambitious.

  24. Tools Required • Text editor, • Terminal, • script/server, • http://api.rubyonrails.org/, • http://www.ruby-doc.org/core/, • http://guides.rubyonrails.org/, • script/console

More Related