1 / 26

Ruby on Rails

Ruby on Rails. Web development that doesn’t hurt. By Mylore, Dung, Lee, Karen and Bryan. Overview. Ruby on Rails Ruby language MVC design pattern AJAX on Rails Ruby on Rails in action. Ruby on Rails. Framework written in the Ruby programming language for database-backed web applications

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 Web development that doesn’t hurt By Mylore, Dung, Lee, Karen and Bryan

  2. Overview • Ruby on Rails • Ruby language • MVC design pattern • AJAX on Rails • Ruby on Rails in action

  3. Ruby on Rails • Framework written in the Ruby programming language for database-backed web applications • Utilizes MVC design pattern • Created by David Heinemeier Hansson in mid 2003 and released in 2004 • Developed to create the Basecamp project management web application

  4. Philosophy • Convention over configuration • Almost no configuration files • Helper scripts to get started • Conformity through freebies • Magic wiring relies on common structures due to conventions of Ruby on Rails • Best practices by invitation • Auto-generated unit and integration testing

  5. Built-in Functions • Helper scripts • Create directory hierarchy and skeleton code • Create model, view and controller objects • Set up database connectivity • ActiveRecord • Dynamic method generation • Built-in WEBrick web server

  6. Ruby • Object Oriented Scripting Language • Interpreted • Open Source • Fully OO that simulates procedurals • Publicly released in 1995 • New but well documented • Based loosely of Eiffel and Ada but heavily influenced by other languages like Perl, Python, Java/JavaScript, etc.

  7. Reflective Language • Ruby incorporates many beneficial features of other languages • Flexible programming (Perl) • Built in regex (Perl) • Error and Exception Handling (Python, Java) • Mark and Sweep Garbage Collector (Java) • No variable declaration (Perl, PHP, etc) • Embedded doc tools, RDoc (Java) • No Semicolon ‘;’ ! (Python) • And many others

  8. Highlights: Open Classes • Every class, including the core classes can be modified at any time. • You just need to call Class class_name #modification code End • Example: #modding floats to output in currency class Float def to_m sprintf("$%.2f", self) end end

  9. Highlights: Embedded Strings • In Perl and PHP you can embed variables into strings. In Ruby you can embed whole blocks of code into string. • Just need to put it between #{ } • Example: #print out the prices in currency format from an #array without the need to put it back into a #variable p = [1.25, 2.00, 3.15] print “Lily: #{p[0].to_m} Rose: #{p[1].to_m} Viola: #{p[2].to_m}”

  10. Highlights: RHTML • Ruby can be directly embedded into HTML much like the way PHP does • Example: <b>Names of all the people</b> <% for person in @people %> Name: <%= person.name %><br/> <% end %>

  11. Future of Ruby • Ruby is easy to learn, simple to understand and friendly to write in • It has become quite popular and gained a large following since its release • Ruby’s library is expanding rapidly with many modules currently being written for it. And with the soon to be release version 1.9 • It’s free!

  12. Rails and the MVC Pattern • MVC in PHP/Perl/JSP is hard • Can be done, but requires a lot of work to create a framework to enforce the MVC pattern. • Java (Struts), Perl (Maypole), and for PHP have their own frameworks, but they are not integrated deeply in their respective languages.

  13. Rails and the MVC Pattern • RoR integrates and enforces MVC in its framework. • Scalability and maintainability. • This significantly reduces the amount of repeated code.

  14. Model • The Model in RoR wraps to represent the RDBMS tables used for a site. • Minimal amount of configuration • Based on the Active Record pattern.

  15. View • Uses embedded ruby code in .rhtml files. Similar to PHP and JSP. • <html> <head>..etc… <% Handle Ruby statements here in embedded. %> </body></html>

  16. Controller • The controller handles the logic, and responds to user interaction and manipulates the model. • Provides CRUD (Create/Read/Update/Delete) operations on the model.

  17. Putting it all together • RoR requires minimal configuration for implementing MVC. Once a new RoR project is created, the framework will automatically create the MVC components. Each component will map to each other with little configuration.

  18. AJAX on Rails • Ability to incorporate AJAX (Asychronous JavaScript and XML) into Rails-driven sites • Contains the Prototype JavaScript library • Works with AJAX functions • Works with Script.aculo.us (additional functionality onto Prototype) • Contains helper functions for implementing AJAX

  19. AJAX on Rails • No longer a complicated process to incorporate AJAX onto Rails-driven sites • Newest version of Rails contains RJS • Create JavaScript using Ruby • Reduce the amount of code needed to implement AJAX

  20. Applications and Projects • Applications • Instiki • Web pages • DRTV Research • Penny Arcade

  21. Applications: Instiki • Wiki-based program that focuses on ease of installation and simplicity in running • 2 step method for install • Simplistic user interface • Great for notes, brainstorming, organizing gatherings, file sharing, etc. • Used for creating and editing web pages • Used for database interaction, syntax interpretation, etc.

  22. Web pages: DRTV Research • DRTV Research is a free online application that combines television lineup listings per week with consumer demographic data for North America. • Over 700,000 pages of data are available on DRTV Research with new data added daily.

  23. Web pages: Penny Arcade • Penny Arcade is among the most popular web-comics currently online, hosting both a children's charity (Child’s Play) and a gaming convention (PAX) each year.

  24. Ruby on Rails: Cons • Confined to one language: Ruby • Slight Learning Curve • Forced to one directory hierarchy • Not too popular (Though it is becoming more so recently) • Not yet industry standard • Relatively new with future stability unknown

  25. Ruby on Rails: Pros • Open Source and free! • Built for Rapid Application Development • Less development time • Less lines of code • Easy database connectivity • MVC design pattern • Built-in functions • Minimal configuration • Well documented • AJAX made easy

  26. Simplicity • Weblog in 15 minutes! • http://media.rubyonrails.org/video/rails_take2_with_sound.mov • Ruby search engine • http://ruby.gsmdev.com

More Related