An Introduction to Ruby and Rails

An Introduction to Ruby and Rails

An Introduction to Ruby and Rails This paper was originally presented at the Southwest Fox conference in Gilbert, Arizona in October, 2010. http://www.swfox.net An Introduction to Ruby and Rails Rick Borup Information Technology Associates 701 Devonshire Dr, Suite 127 Champaign, IL 61820 Voice: (217) 359-0918 Fax: (217) 398-0413 Email: [email protected] Ruby is a powerful, object-oriented, open-source language with a clean and easily understandable syntax. Originally released to the public in 1995, wide-spread interest in the Ruby language really began to take off in 2003 with the release of the Ruby on Rails® framework. Also known as "RoR" or simply "Rails", Ruby on Rails is an open-source Web framework that makes it possible to quickly and easily create data-based Web applications. Together, the Ruby language and the Ruby on Rails framework can become an exciting and powerful addition to any developer's toolbox. This session introduces both the Ruby language and the Rails framework, focusing on their installation and use on a Windows® platform with a perspective geared toward experienced Visual FoxPro® developers. © 2010 Rick Borup Page 1 of 64 An Introduction to Ruby and Rails Table of Contents Introduction............................................................................................................................................................ 4 Installing Ruby and Rails on Windows......................................................................................................... 4 Installing Instant Rails ................................................................................................................................... 5 Installing with RubyInstaller....................................................................................................................... 7 Ruby versions............................................................................................................................................... 8 Installing Ruby 1.8.7 .................................................................................................................................. 8 RubyGems ....................................................................................................................................................10 Installing Rails............................................................................................................................................13 Installing Mongrel.....................................................................................................................................15 Installing SQLite.........................................................................................................................................15 Installing Git................................................................................................................................................16 The finished installation.........................................................................................................................17 Optional system configuration changes................................................................................................18 Customize the command window ......................................................................................................18 Add Ruby to your path ............................................................................................................................18 Easily clear the IRB console ..................................................................................................................18 And now for something completely different..........................................................................................19 Working with Ruby on Windows .................................................................................................................20 Interactive Ruby.............................................................................................................................................20 Stand-alone editors.......................................................................................................................................21 IDE-style editors.............................................................................................................................................22 The Ruby programming language................................................................................................................22 Similarities to and differences from Visual FoxPro..........................................................................23 Ruby naming conventions..........................................................................................................................24 Ruby data types and objects......................................................................................................................26 Strings............................................................................................................................................................26 Numeric values ..........................................................................................................................................26 Arrays ............................................................................................................................................................27 Hashes ...........................................................................................................................................................27 Ranges ...........................................................................................................................................................28 Symbols.........................................................................................................................................................29 © 2010 Rick Borup Page 2 of 64 An Introduction to Ruby and Rails Ruby operators ...............................................................................................................................................30 Ruby conditionals ..........................................................................................................................................30 Ruby loop structures ....................................................................................................................................32 Ruby iterators .................................................................................................................................................33 Ruby program structure..............................................................................................................................34 Methods ........................................................................................................................................................34 Classes ...........................................................................................................................................................35 Modules.........................................................................................................................................................38 Ruby language summary.............................................................................................................................42 The Rails framework.........................................................................................................................................42 The MVC pattern ............................................................................................................................................42 Routes and REST............................................................................................................................................43 The ActiveRecord ORM................................................................................................................................44 Creating a Rails app ......................................................................................................................................44 Running the app .............................................................................................................................................45 Creating a database.......................................................................................................................................48 Database migrations.....................................................................................................................................50 Using the app...................................................................................................................................................52 Peering behind the curtains.......................................................................................................................54 Config files....................................................................................................................................................54 Database files..............................................................................................................................................55 MVC files.......................................................................................................................................................56 RESTful URLs...................................................................................................................................................60

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    64 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us