Your SlideShare is downloading. ×
Getting On Board Ruby on Rails - Rails presentation
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Getting On Board Ruby on Rails - Rails presentation

4,533
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
4,533
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
21
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Getting On Board Ruby on RailsGetting On Board Ruby on Rails Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin – Eau ClaireUniversity of Wisconsin – Eau Claire
  • 2. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails  Framework is two years oldFramework is two years old  New way to develop web-basedNew way to develop web-based applicationsapplications  Lots of converts from other languagesLots of converts from other languages What's the buzzWhat's the buzz
  • 3. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails  New web-to-database systemsNew web-to-database systems  Migrations from existing PHP, ASP, or PerlMigrations from existing PHP, ASP, or Perl systemssystems  An alternative to non-Enterprise J2EEAn alternative to non-Enterprise J2EE systemssystems –Systems in that gap between simple scripts andSystems in that gap between simple scripts and complex enterprise systemscomplex enterprise systems When to use RailsWhen to use Rails
  • 4. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby OnGetting On Board Ruby On RailsRails  Simple scriptsSimple scripts  Non-web projectsNon-web projects  Complex systems with legacy databasesComplex systems with legacy databases –Possible to do but you will lose productivity gainsPossible to do but you will lose productivity gains When NOT to use RailsWhen NOT to use Rails
  • 5. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails  Web-based administrative systems forWeb-based administrative systems for administrative and academic officesadministrative and academic offices –Housing and Residence LifeHousing and Residence Life –Student Health ServicesStudent Health Services –Music and Theater ArtsMusic and Theater Arts –Continuing EducationContinuing Education  Developed by student developersDeveloped by student developers –New developers every couple of yearsNew developers every couple of years –Team-based approach whenever possibleTeam-based approach whenever possible How UW-Eau Claire Uses ItHow UW-Eau Claire Uses It
  • 6. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails  Rapid prototypingRapid prototyping  Built-in testingBuilt-in testing  Easy to maintain and upgradeEasy to maintain and upgrade  Friendly user communityFriendly user community  Easy to learn, embrace and extendEasy to learn, embrace and extend  It’s agile!It’s agile! Key BenefitsKey Benefits
  • 7. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails Who’s Using RailsWho’s Using Rails  Penny ArcadePenny Arcade  AListApartAListApart  GustoGusto  ShopifyShopify  StrongspaceStrongspace  Yakima-Herald TelegramYakima-Herald Telegram  SubtopicSubtopic
  • 8. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails Rails and the MVC PatternRails and the MVC Pattern  Model - View - ControllerModel - View - Controller  Rails follows this pattern veryRails follows this pattern very strictlystrictly  Rails adds some extra componentsRails adds some extra components to this patternto this pattern
  • 9. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails ModelsModels ■ Provide access to database tablesProvide access to database tables ■ Contain business rulesContain business rules ■Record CRUD (Create, Read, Update,Record CRUD (Create, Read, Update, Delete)Delete) ■ An instance represents a row in a tableAn instance represents a row in a table ■Grade model instance => one row fromGrade model instance => one row from ‘grades’ table‘grades’ table
  • 10. ModelModel  Models also define validations and associationsModels also define validations and associations with other models.with other models.
  • 11. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails ModelsModels Provided by mboffin.comProvided by mboffin.com
  • 12. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails ControllersControllers  Handle user requestsHandle user requests  Retrieve data from modelsRetrieve data from models  Invoke methods on modelsInvoke methods on models  Send views and responses to usersSend views and responses to users  Should contain no business logicShould contain no business logic –Only flow controlOnly flow control
  • 13. ControllersControllers  Here’s a basic controller action to display a blog postHere’s a basic controller action to display a blog post  The URL would be /blog/show/1The URL would be /blog/show/1
  • 14. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails ViewsViews  The user screens or web pages of yourThe user screens or web pages of your applicationsapplications  Should contain no business logicShould contain no business logic  Should not know about modelsShould not know about models  Should contain very little presentationShould contain very little presentation logic whenever possiblelogic whenever possible –Helpers are used for thisHelpers are used for this
  • 15. ViewView  Views are similar to PHP or ASP pagesViews are similar to PHP or ASP pages  Much more powerfulMuch more powerful  Partials can be used to make our work easierPartials can be used to make our work easier
  • 16. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails Rails-specific MVC componentsRails-specific MVC components  HelpersHelpers  PartialsPartials  LayoutsLayouts
  • 17. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails HelpersHelpers  Place to put presentation logicPlace to put presentation logic  Available to Views and controllersAvailable to Views and controllers  Rails has hundreds of built-in helpers forRails has hundreds of built-in helpers for your viewsyour views  Easy to make your ownEasy to make your own
  • 18. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails PartialsPartials  Pieces of view code that can be reusedPieces of view code that can be reused –Can be applied to a collection of data!Can be applied to a collection of data!  Designed to be shared across multiple viewsDesigned to be shared across multiple views  ExamplesExamples –Form fields for Create and Update pagesForm fields for Create and Update pages –Search resultsSearch results –TablesTables –Table rowsTable rows
  • 19. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails LayoutsLayouts  Your templates are here.Your templates are here.  Global or controller-specificGlobal or controller-specific  No need for header and footer separationNo need for header and footer separation –Rails reads the template last and places yourRails reads the template last and places your application within the content regionapplication within the content region  Easy for designers to create layouts withoutEasy for designers to create layouts without knowing Railsknowing Rails
  • 20. LayoutsLayouts Your rendered view is inserted here!
  • 21. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails MigrationsMigrations  Database-independent schema definitionDatabase-independent schema definition  Incrementally define your databaseIncrementally define your database  Makes creation and recreation easy!Makes creation and recreation easy! I’m platform- independent!
  • 22. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails ScaffoldingScaffolding  Generation of controllers and views basedGeneration of controllers and views based on model definitionon model definition  Not meant for production use!Not meant for production use! –Needs tweaking firstNeeds tweaking first
  • 23. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails Demo!Demo!
  • 24. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails ScalabilityScalability  Rails scales horizontallyRails scales horizontally  When load is too high, bring up anotherWhen load is too high, bring up another instance of the app & load balance your trafficinstance of the app & load balance your traffic  Simple solutions for load-balancingSimple solutions for load-balancing –Apache 2.2 + mod_proxy_balanceApache 2.2 + mod_proxy_balance –PoundPound –Pen (Easy but no SSL support)Pen (Easy but no SSL support) –Lighttpd + mod_proxyLighttpd + mod_proxy
  • 25. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails Scalability (continued)Scalability (continued)  Know your current requirementsKnow your current requirements  ““100 users at the same time” isn’t a good benchmark100 users at the same time” isn’t a good benchmark –Simultaneous actions don’t happen all the timeSimultaneous actions don’t happen all the time  Think “requests per second”Think “requests per second” –Measure your existing apps and see how Rails compares.Measure your existing apps and see how Rails compares.  Your database is often the first scalability problemYour database is often the first scalability problem you’ll encounter in any web applicationyou’ll encounter in any web application –Databases can be clusteredDatabases can be clustered
  • 26. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails PerformancePerformance  Rails performs on par with other languagesRails performs on par with other languages  Slower on WindowsSlower on Windows –Limitation of compiled Ruby on WindowsLimitation of compiled Ruby on Windows  My tests on similar hardwareMy tests on similar hardware –7 req/sec to 35 req/sec on Windows7 req/sec to 35 req/sec on Windows –30 req/second to 150 req/second on Linux30 req/second to 150 req/second on Linux  Increase load by adding more “dispatchers”Increase load by adding more “dispatchers” and load-balancing themand load-balancing them
  • 27. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails DeploymentDeployment  Linux is the best for deploymentLinux is the best for deployment  Windows is supportedWindows is supported –IIS won’t work well, if at allIIS won’t work well, if at all –Simple workarounds for this existSimple workarounds for this exist  Shared Hosting providers supporting RailsShared Hosting providers supporting Rails –Dreamhost (Great for personal stuff)Dreamhost (Great for personal stuff) –BlueHostBlueHost –RailsPlaygroundRailsPlayground  High-availability providersHigh-availability providers –RailsMachineRailsMachine –EngineYardEngineYard
  • 28. DeploymentDeployment
  • 29. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails SecuritySecurity  Security is a people problemSecurity is a people problem –Developers must ensure security of their code and dataDevelopers must ensure security of their code and data –System admins must keep their systems up to dateSystem admins must keep their systems up to date  Rails has built-in mechanisms for preventing SQLRails has built-in mechanisms for preventing SQL injection and XSSinjection and XSS  Rails is as secure as any other server-sideRails is as secure as any other server-side languagelanguage  How secure is your platform underneath the webHow secure is your platform underneath the web application?application?
  • 30. Choosing a Development LanguageChoosing a Development Language  MyDecisionHelperMyDecisionHelper – Helps you make critical decision using aHelps you make critical decision using a patent-pending decision enginepatent-pending decision engine – Rails application developed by a team of fiveRails application developed by a team of five  Two Rails programmers, one designer, oneTwo Rails programmers, one designer, one consultant, and one market analyst, each workingconsultant, and one market analyst, each working less than 20 hours per weekless than 20 hours per week  Developers are new to RailsDevelopers are new to Rails  One developer made more progress in oneOne developer made more progress in one weekend than in 3 months with .Net!weekend than in 3 months with .Net!  What you see didn’t exist 2 months ago!What you see didn’t exist 2 months ago!
  • 31. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails Resources - BooksResources - Books  Learn to ProgramLearn to Program (Chris Pine)(Chris Pine)  Agile Web Development with RailsAgile Web Development with Rails (Dave(Dave Thomas and David Heinemeier Hansson)Thomas and David Heinemeier Hansson)  Ruby for Rails,Ruby for Rails, Ruby techniques for RailsRuby techniques for Rails developersdevelopers (David Black)(David Black)  Programming RubyProgramming Ruby (Dave Thomas)(Dave Thomas)  Rails RecipesRails Recipes (Chad Fowler)(Chad Fowler)
  • 32. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails Resources – Web SitesResources – Web Sites  www.rubyonrails.orgwww.rubyonrails.org  wiki.rubyonrails.comwiki.rubyonrails.com  api.rubyonrails.orgapi.rubyonrails.org  www.uwec.edu/webdev/rorwww.uwec.edu/webdev/ror for additionalfor additional resourcesresources
  • 33. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails Resources – Mailing ListResources – Mailing List  groups.google.com/group/rubyonrailsgroups.google.com/group/rubyonrails-talk-talk
  • 34. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails Resources - OtherResources - Other  #rubyonrails on irc.freenode.org#rubyonrails on irc.freenode.org  Email Brian any timeEmail Brian any time –hoganbp@uwec.eduhoganbp@uwec.edu –bphogan@gmail.combphogan@gmail.com  Contact Brian any time after the presentationContact Brian any time after the presentation
  • 35. Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis University of Wisconsin-EauUniversity of Wisconsin-Eau ClaireClaire Getting On Board Ruby On RailsGetting On Board Ruby On Rails Thanks for coming!Thanks for coming!
  • 36. Getting On Board Ruby onGetting On Board Ruby on RailsRails Brian HoganBrian Hogan hoganbp@uwec.eduhoganbp@uwec.edu Lillian HillisLillian Hillis hillislf@uwec.eduhillislf@uwec.edu