ruby on rails ruby on rails
play

Ruby on Rails Ruby on Rails a high- -productivity productivity a - PowerPoint PPT Presentation

Ruby on Rails Ruby on Rails a high- -productivity productivity a high web application framework web application framework http://blog blog. .curthibbs curthibbs.us/ .us/ Curt Hibbs <curt@hibbs.com> http:// Curt Hibbs


  1. Ruby on Rails Ruby on Rails a high- -productivity productivity a high web application framework web application framework http://blog blog. .curthibbs curthibbs.us/ .us/ Curt Hibbs <curt@hibbs.com> http:// Curt Hibbs <curt@hibbs.com>

  2. Agenda Agenda � What is Ruby? � What is Ruby? � What is Rails? � What is Rails? � Live Demonstration (sort of…) � Live Demonstration (sort of…) � Metrics for Production � Metrics for Production Rails Applications Rails Applications � Resources for more information � Resources for more information

  3. What is Ruby? What is Ruby? � Short Answer: � Short Answer: � Ruby is the successful combination of: � Ruby is the successful combination of: • Smalltalk's conceptual elegance, Smalltalk's conceptual elegance, • • Python's ease of use and learning, and Python's ease of use and learning, and • • • Perl's pragmatism. Perl's pragmatism. � Long Answer: � Long Answer: � Well… see the following slides. � Well… see the following slides.

  4. What is Ruby? What is Ruby? Ruby is… Ruby is… Interpreted Interpreted Like Like Perl Perl, Python , Python Object- -Oriented Oriented Object Like Smalltalk, Eiffel, Ada Ada, Java , Java Like Smalltalk, Eiffel, Rapidly Gaining Mindshare in US and Europe Rapidly Gaining Mindshare in US and Europe Originated in Japan, very popular there Originated in Japan, very popular there

  5. Why Ruby? Why Ruby? � Easy to learn � Easy to learn � Open source (very liberal license) � Open source (very liberal license) � Rich libraries � Rich libraries � Very easy to extend � Very easy to extend � Truly Object � Truly Object- -Oriented Oriented � Everything is an object (no primitives) � Everything is an object (no primitives) � Single inheritance ( � Single inheritance (mixins mixins give you the power give you the power of multiple inheritance with the problems). of multiple inheritance with the problems). � Helpful community � Helpful community

  6. Why Ruby? Why Ruby? � Dynamic Features � Dynamic Features � Duck Typing � Duck Typing (uses method signatures, not class (uses method signatures, not class inheritance) inheritance) � Method calls are actually messages sent to an � Method calls are actually messages sent to an object instance object instance � Open classes � Open classes � Reflection � Reflection � Bottom Line: write more understandable � Bottom Line: write more understandable code in fewer lines code in fewer lines � Less code means fewer bugs � Less code means fewer bugs

  7. Why Not? Why Not? � Performance � Performance � although it rivals � although it rivals Perl Perl and Python and Python � Threading model � Threading model � Does not use native threads � Does not use native threads

  8. Sample Ruby Code Sample Ruby Code Code courtesy of John W. Long Code courtesy of John W. Long

  9. What is Rails? What is Rails? � Short Answer: � Short Answer: � An � An extremely extremely productive web productive web- -application application framework that is written in Ruby by framework that is written in Ruby by David Heinemeier Hansson. David Heinemeier Hansson. � Long Answer: � Long Answer: � Well… see the following slides. � Well… see the following slides.

  10. What is Rails? What is Rails? � Full Stack Framework � Full Stack Framework � Includes everything needed to create a � Includes everything needed to create a database- -driven web application using the driven web application using the database Model- -View View- -Controller pattern. Controller pattern. Model � Being a full � Being a full- -stack framework means that all stack framework means that all layers are built to work seamlessly together. layers are built to work seamlessly together. � That way you Don’t Repeat Yourself (DRY). � That way you Don’t Repeat Yourself (DRY).

  11. What is Rails? What is Rails? � Less Code � Less Code � Requires fewer total lines of code than other � Requires fewer total lines of code than other frameworks spend setting up their XML frameworks spend setting up their XML configuration files. configuration files. � Convention over Configuration � Convention over Configuration � Rails shuns configuration files in favor of � Rails shuns configuration files in favor of conventions, reflection and dynamic run- -time time conventions, reflection and dynamic run extensions. extensions. � Configure your application by making it � Configure your application by making it � Your code and database schema � Your code and database schema are are the the configuration! configuration! � No compilation phase � No compilation phase • • Make a change, see it work. Make a change, see it work.

  12. What is Rails? What is Rails? Rails and MVC Rails and MVC � Model (ActiveRecord) � Model (ActiveRecord) � Maintains the relationship between Object and � Maintains the relationship between Object and Database Database � Handles validation, association, � Handles validation, association, transations transations, , and more… and more… � Does not completely insulate the developer � Does not completely insulate the developer from SQL from SQL

  13. What is Rails? What is Rails? Rails and MVC Rails and MVC � View ( � View (ActionView ActionView) ) � Script � Script- -based based templating templating system (like JSP, system (like JSP, ASP, PHP, etc.) ASP, PHP, etc.) � Tight controller integration � Tight controller integration � Reusable components � Reusable components � Integrated, easy to use Ajax support. � Integrated, easy to use Ajax support.

  14. What is Rails? What is Rails? Rails and MVC Rails and MVC � Controller ( � Controller (ActionController ActionController) ) � Reflection ties actions to methods � Reflection ties actions to methods � Tight view integration � Tight view integration � Filters, layouts, caching, sessions, etc. � Filters, layouts, caching, sessions, etc.

  15. Rails Demonstration Rails Demonstration Play cookbook-video.exe , a video showing development of cookbook web application from ONLamp.com article Rolling with Ruby on Rails : http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html

  16. Database Support Database Support � Supported Databases � Supported Databases � MySQL � MySQL � PostgreSQL � PostgreSQL � SQLite � SQLite � SQL Server � SQL Server � Coming Soon � Coming Soon � Oracle � Oracle � DB2 � DB2 � Firebird � Firebird � more… � more…

  17. Model Objects Model Objects � ActiveRecord � ActiveRecord � Uses reflection extensively � Uses reflection extensively � Automated mapping between � Automated mapping between • classes and tables classes and tables • • Attributes and columns Attributes and columns • � Dynamically generates � Dynamically generates accessors accessors, finders, and , finders, and validators. . validators � Best with new DB schemas � Best with new DB schemas

  18. Controllers Controllers � ActionController � ActionController � Rails URLs are typically of the form � Rails URLs are typically of the form “/controller/action” “/controller/action” � A controller is implemented by a class. � A controller is implemented by a class. � Actions map to methods in the controller � Actions map to methods in the controller � Implicit action � Implicit action- -to to- -view mapping view mapping

  19. Views Views � ActionView � ActionView � Named (by default) after the action that � Named (by default) after the action that renders them. renders them. � Embeds Ruby code in the template � Embeds Ruby code in the template (similar to JSP, ASP, PHP, etc.) (similar to JSP, ASP, PHP, etc.) � Have access to (some) of the controller’s state � Have access to (some) of the controller’s state

  20. Server Configurations Server Configurations � WEBrick � WEBrick • Built Built- -in to Rails in to Rails • • Good development environment Good development environment • � Apache/CGI � Apache/CGI • Easy to set up, but slow Easy to set up, but slow • � Apache/mod_ruby � Apache/mod_ruby • Ruby interpreter per Apache process Ruby interpreter per Apache process • � Apache/mod_ � Apache/mod_fastcgi fastcgi • • Pool of Ruby processes Pool of Ruby processes � Lighttpd � Lighttpd • Built Built- -in in fastcgi fastcgi support support • • • Small footprint, high performance Small footprint, high performance

  21. But Does it Scale? But Does it Scale? Commercial Rails Applications Commercial Rails Applications � � Basecamp Basecamp • http://www. http://www.basecamphq basecamphq.com .com • � � 43 Things 43 Things • • http://43things.com http://43things.com � Ta � Ta- -Da Da Lists Lists • http:// http://tadalists tadalists.com .com • � Snowdevil � Snowdevil • http://www. http://www.snowdevil snowdevil.ca .ca • � Bellybutton � Bellybutton • http://www.bellybutton.de http://www.bellybutton.de • � � Backpack Backpack • • http://www. http://www.backpackit backpackit.com/ .com/

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend