rubyonrails
Post on 12-May-2015
1.198 Views
Preview:
TRANSCRIPT
Getting On Board Ruby on Getting On Board Ruby on RailsRails
Brian Hogan and Lillian HillisBrian Hogan and Lillian Hillis
University of Wisconsin – Eau ClaireUniversity of Wisconsin – Eau Claire
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
Framework is two years oldFramework is two years old New way to develop web-based New way to develop web-based
applications applications Lots of converts from other languagesLots of converts from other languages
What's the buzzWhat's the buzz
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
New web-to-database systemsNew web-to-database systems Migrations from existing PHP, ASP, or Migrations from existing PHP, ASP, or
Perl systemsPerl systems An alternative to non-Enterprise J2EE An alternative to non-Enterprise J2EE
systemssystems–Systems in that gap between simple Systems in that gap between simple scripts and complex enterprise systemsscripts and complex enterprise systems
When to use RailsWhen to use Rails
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
Simple scriptsSimple scripts Non-web projectsNon-web projects Complex systems with legacy Complex systems with legacy
databasesdatabases–Possible to do but you will lose productivity Possible to do but you will lose productivity gainsgains
When NOT to use RailsWhen NOT to use Rails
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
Web-based administrative Web-based administrative systems for administrative and systems for administrative and academic officesacademic 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
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
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
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
Who’s Using RailsWho’s Using Rails
Penny ArcadePenny Arcade AListApartAListApart GustoGusto ShopifyShopify StrongspaceStrongspace Yakima-Herald TelegramYakima-Herald Telegram SubtopicSubtopic
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
Rails and the MVC PatternRails and the MVC Pattern
Model - View - ControllerModel - View - Controller Rails follows this pattern very Rails follows this pattern very
strictlystrictly Rails adds some extra Rails adds some extra
components to this patterncomponents to this pattern
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
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 Grade model instance => one row from ‘grades’ tablefrom ‘grades’ table
ModelModel
Models also define validations and Models also define validations and associations with other models.associations with other models.
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
ModelsModels
Provided by mboffin.comProvided by mboffin.com
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
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
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
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
ViewsViews
The user screens or web pages of The user screens or web pages of your applicationsyour applications
Should contain no business logicShould contain no business logic Should not know about modelsShould not know about models Should contain very little Should contain very little
presentation logic whenever possiblepresentation logic whenever possible–Helpers are used for thisHelpers are used for this
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
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
Rails-specific MVC componentsRails-specific MVC components
HelpersHelpers PartialsPartials LayoutsLayouts
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
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 Rails has hundreds of built-in helpers
for your viewsfor your views Easy to make your ownEasy to make your own
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
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 Designed to be shared across multiple viewsviews
ExamplesExamples–Form fields for Create and Update pagesForm fields for Create and Update pages–Search resultsSearch results–TablesTables–Table rowsTable rows
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
LayoutsLayouts
Your templates are here.Your templates are here. Global or controller-specificGlobal or controller-specific No need for header and footer No need for header and footer
separationseparation–Rails reads the template last and places Rails reads the template last and places your application within the content regionyour application within the content region
Easy for designers to create layouts Easy for designers to create layouts without knowing Railswithout knowing Rails
LayoutsLayouts
Your rendered view is inserted here!
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
MigrationsMigrations
Database-independent schema Database-independent schema definitiondefinition
Incrementally define your databaseIncrementally define your database Makes creation and recreation easy!Makes creation and recreation easy!I’m platform-
independent!
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
ScaffoldingScaffolding
Generation of controllers and views Generation of controllers and views based on model definitionbased on model definition
Not meant for production use!Not meant for production use!–Needs tweaking firstNeeds tweaking first
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
Demo!Demo!
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
ScalabilityScalability
Rails scales horizontallyRails scales horizontally When load is too high, bring up another When load is too high, bring up another
instance of the app & load balance your instance of the app & load balance your traffictraffic
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
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
Scalability (continued)Scalability (continued)
Know your current requirementsKnow your current requirements ““100 users at the same time” isn’t a good 100 users at the same time” isn’t a good
benchmarkbenchmark–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 Measure your existing apps and see how Rails compares.compares.
Your database is often the first scalability Your database is often the first scalability problem you’ll encounter in any web applicationproblem you’ll encounter in any web application–Databases can be clusteredDatabases can be clustered
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
PerformancePerformance
Rails performs on par with other Rails performs on par with other languageslanguages
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 Increase load by adding more “dispatchers” and load-balancing them“dispatchers” and load-balancing them
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
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 providers High-availability providers –RailsMachineRailsMachine–EngineYardEngineYard
DeploymentDeployment
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
SecuritySecurity Security is a people problemSecurity is a people problem
–Developers must ensure security of their code and Developers must ensure security of their code and datadata
–System admins must keep their systems up to dateSystem admins must keep their systems up to date Rails has built-in mechanisms for preventing Rails has built-in mechanisms for preventing
SQL injection and XSSSQL injection and XSS Rails is as secure as any other server-side Rails is as secure as any other server-side
languagelanguage How secure is your platform underneath the How secure is your platform underneath the
web application?web application?
Choosing a Development Choosing a Development LanguageLanguage
MyDecisionHelperMyDecisionHelper– Helps you make critical decision using a Helps you make critical decision using a
patent-pending decision enginepatent-pending decision engine– Rails application developed by a team of Rails application developed by a team of
fivefive Two Rails programmers, one designer, one Two Rails programmers, one designer, one
consultant, and one market analyst, each consultant, and one market analyst, each working less than 20 hours per weekworking less than 20 hours per week
Developers are new to RailsDevelopers are new to Rails One developer made more progress in one One 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!
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
Resources - BooksResources - Books
Learn to ProgramLearn to Program (Chris Pine) (Chris Pine) Agile Web Development with RailsAgile Web Development with Rails
(Dave Thomas and David Heinemeier (Dave Thomas and David Heinemeier Hansson)Hansson)
Ruby for Rails, Ruby for Rails, Ruby techniques for Rails Ruby techniques for Rails developersdevelopers (David Black) (David Black)
Programming RubyProgramming Ruby (Dave Thomas) (Dave Thomas) Rails RecipesRails Recipes (Chad Fowler) (Chad Fowler)
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
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 for
additional resourcesadditional resources
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
Resources – Mailing ListResources – Mailing List
groups.google.com/group/rubyonrailsgroups.google.com/group/rubyonrails-talk-talk
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On Getting On Board Ruby On RailsRails
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 Contact Brian any time after the presentationpresentation
Brian Hogan and Lillian HillisBrian Hogan and Lillian HillisUniversity of Wisconsin-Eau University of Wisconsin-Eau ClaireClaire
Getting On Board Ruby On RailsGetting On Board Ruby On Rails
Thanks for coming!Thanks for coming!
Getting On Board Ruby on Getting On Board Ruby on RailsRails
Brian HoganBrian Hoganhoganbp@uwec.ehoganbp@uwec.edudu
Lillian HillisLillian Hillishillislf@uwec.eduhillislf@uwec.edu
top related