SlideShare a Scribd company logo
Using Rails to Create an Enterprise App: A Real-Life Case Study By David Keener http://www.keenertech.com AOL proprietary information used with permission.
Overview Multiple databases; of multiple types A Legacy database (Remedy) Significant AJAX functionality Search capability Email (or corporate spam) Ruby on Rails is clearly an exciting and ground-breaking technology. But how good is it at solving the types of problems that corporate developers need to solve?   My team put Rails to the test in a real-world internal application for AOL that’s used by hundreds of employees. This case study, the  Exception Request Tool , is a non-trivial application that features:
What We Wanted to Know Does Rails really speed up development? Can it be effectively integrated with legacy databases? How hard is it to set up a Rails production environment? How hard is it to incorporate AJAX and build  Web 2.0  applications? How effective is Rails at generating and sending automated emails? What pitfalls should developers watch out for? The underlying question affecting the adoption of Rails for corporate development is: “How good is it at producing web sites that aren’t blogs?”
Rails Adoption Rails is in a unique place, just to the left of the “Chasm”. Its capacity for successful delivery of real business applications will probably be a key factor in crossing the chasm between early adopters and widespread adoption.  From:  Diffusion of Innovations , by E. M. Rogers, 1995
The Case Study Application Relatively standard CRUD features, plus…. Confirm and edit capabilities for requests A search feature A history feature (for Sarbanes-Oxley support) Administrative capability to modify  all  aspects of a request Automated emails of various types Approval mechanism for upper management Access to legacy database (Remedy) The Exception Request Tool (ERT) allows AOL employees to request production installs for time periods when such installs are not normally allowed. Key features included:
Database Objects Request : A request for a production install to support one or more business areas Unit : A collection of items to be installed to support a business area Install Item : Something to be installed, usually software Approver : A person who approves a unit, or a set of install items Exception Types : For metrics, categorizes aspects of each install item Exception Type Request Unit Install Item Approver
Exception Request Tool Screenshot used with AOL permission.
Process Change Rails facilitated delivery of an early prototype  while  requirements were still being drafted The prototype helped generate lots of new requirements via discussion of real screens & functionality New requirements led to major scope creep, which… Totally blew the original deadline But the customer was happier…the product was really what  they  wanted So the customer agreed to adopt a more “agile” approach to development going forward The first, and perhaps most striking, change due to Rails, was its impact on the development process.
Environments Dev Environments: Easily set up on Mac & Windows Production Environment: Apache 2.2, Mongrel, Mongrel Cluster, etc. System administrators have no experience setting up Rails environments – falls to the dev team No standardization of Rails environments & recommended plug-ins – falls to the dev team At AOL: No access from prod box to outside Internet Need to allocate a non-trivial amount of time to deal with environment setup issues Applications need a place to run, where they will be properly supported. Environment set-up was  not  a trivial exercise.
Database Support Rails is somewhat immature in the realm of database support, though improving Sterling support for MySQL, but other databases can be more problematic Oracle support is good  Support for Sybase is  pathetic  – Got it working for Linux, but not for Windows and Mac If not using MySQL, need to allocate time to address database connectivity issues
Migrations Migrations simplify database builds Database neutral A truly wonderful feature Don’t know how I lived without them Can also set up test data / lookup data class CreateRiskLookup < ActiveRecord::Migration def self.up create_table :btr_risk_lookup do |t| # t.column :name, :string t.column :risk_name, :string, :null=>false, :limit => 50 t.column :risk_desc, :string, :null=>true, :limit => 100 end end def self.down drop_table :btr_risk_lookup end end
Cross-Database Migration Issues Migrations generally “do the right thing” across databases…but not always Oracle sequences – names too long In model:  set_sequence_name shortname_idx Indices – names too long In migration:   add_index :btr_install_item_exceptions,   [:install_item_id, :exception_type_id], :name => 'btr_installitemex' Indices – delete in Oracle, not MySQL In migration:  Needed conditional logic based on database used.
Conditional Logic in Migrations Perform different actions based on database Only remove legacy table in MySQL (dev) Use class connection, not default Conditional logic also needed for Oracle indices def self.down adapter = User.connection.instance_variable_get(&quot;@config&quot;)[:adapter] puts(&quot;Database Adapter Detected: &quot; + adapter) if adapter == &quot;mysql“ drop_table :btr_users end end
Killer Legacy Database Database: Sybase – Could only get access working in proposed Linux prod environment – No access from development environments Non-numeric primary keys Hundreds of database columns Read-only database access Query Performance Issues Case-sensitive column and table names! Our legacy database put Rails to the test. Our legacy database possessed the following features:
Legacy Database Cheat Sheet Explicitly define the names of legacy tables In model:  set_table_name ‘T135’  # case-sensitive in Sybase Explicitly define the name of the primary key In model:  set_primary_key ‘xyz’  # case-sensitive in Sybase For tables with non-numeric keys, use SQL For tables with 100’s of columns, use SQL With query performance issues, break SQL queries into two parts:  1. Get the ID’s using whatever criteria are needed,  2. Get the subset of desired columns for just those ID’s If doing SQL, create generic methods in model; only the model should have to know about the bare-metal SQL
Dual Query Tactic #  Step 1:  Get a list of matching ticket ID's res = Ticket.find_by_sql(&quot;SELECT Change_Request__ AS Change_Request&quot; + &quot; FROM CM_Change_Mgmt &quot; + &quot; WHERE Component___NUM_ LIKE '&quot; + str + &quot;%'&quot;) #  Step 2:  Convert result set to comma-delimited list of single-quoted ID's lst = bld_list(res) #  Step 3:  Get a subset of the 300+ available columns. By the way, it's # possible that multiple tickets may match tickets = Ticket.find_by_sql( &quot;SELECT CM_Change_Mgmt.Change_Request__ AS Change_Request, &quot; + &quot;CM_Change_Mgmt.Component___NUM_ AS Component, &quot; + &quot;CM_Change_Mgmt.Short_Description, &quot; + &quot;CM_Change_Mgmt.Outage_Tkt_Yes, &quot; + &quot;CM_Change_Mgmt.Outage__ AS Outage_ID, &quot; + &quot;CM_Change_Mgmt.Affects_Members_, &quot; + &quot;CM_Change_Mgmt.NUM__ AS NUMID &quot; + &quot;FROM CM_Change_Mgmt &quot; + &quot;WHERE CM_Change_Mgmt.Change_Request__ IN (&quot; + lst + &quot;) &quot; + &quot;AT isolation 0&quot;)
JavaScript & Validations Rails supports basic JavaScript validations JavaScript takes time, requires testing to support multiple browsers, etc. JavaScript can seriously slow a project Consider custom JavaScript judiciously If JavaScript needs are intense, consider integrating other open source libraries (e.g. – Dojo or others)
Date Manipulation Rails date manipulation features are awesome Rails date entry features are decent Really needed a popup calendar component -  Also needed to be able to validate pairs of dates, i.e. – start and end dates Spent a LOT of time on date-related issues, including integrating popup calendar feature
Popup Calendar Component Popup Calendar - Date selection - Time selection
Email in Rails Rails includes ActionMailer class Easy-to-create email class Emails generated based on templates Easy generation of dual text/html emails Easy configuration Can have emails that mimic the web pages almost exactly Graphic incorporation more problematic Email Features: Incredible!
Sample Email Real-Life Email - Mimics web page - Dual format
Spaminator Model class ExceptionRequestSpaminator < ActionMailer::Base def submit(ex) email_list = @requester.email_address + &quot;,&quot; + get_email_rm subject  = &quot;Exception Request #{ex.id}: SUBMITTED&quot;  intro = &quot;The following exception request was just submitted. To review the request online, click <a  href=#{get_local_url}/show/#{ex.id}>here</a>.&quot; setup_ERT_email(ex, subject, intro, email_list) end def setup_ERT_email(ex, subject, intro, email) @subject  = subject @body  = { :exception_request => ex,  :request_units => ex.request_units, :requester => @requester, :intro => intro} @recipients = email @from  = 'support-services-rm@listserv.sup.aol.com @sent_on  = Time.now @headers  = {} end end
Sending Email Controller: To send an email… ExceptionRequestSpaminator.deliver_submit(@exception_request) Email Template – Just another “.rhtml” page - Template is “submit.text.html.rhtml” Mime Type incorporated into template name Can easily support other formats Email features – easy to implement Not so useful for social networking “green field” apps Incredibly useful for corporate enterprise apps
Testing Rails supports extensive testing features Didn’t use  ANY  of them on the project Not a problem with Rails, but a major deficiency in the project Need to internalize Rails built-in testing features Should incorporate tests as one of the required outputs of each project
Overall Rails “Report Card” – 1 A+ Prototyping: Extremely fast A Agility: Supports agile programming methodologies; not so great for waterfall, etc. A Migrations: excellent; cross-database  support could be stronger A Email: Excellent; great for enterprise sites B Dates: Manipulation excellent (A); date  entry is just OK (C)
Overall Rails “Report Card” - 2 B Testing: Features are good; requires some planning; easiest thing to “drop” B Legacy DB Support: Pretty good; needs more publicity C Database Support: not consistent; still  very immature C JavaScript: Supports basic validations; complex components and validations are more problematic D Environment Setup: Not widely documented; not easy for a production environment * * Note: See JRuby as an alternative environment for Rails applications.
The “Green Field” Perception One of the biggest problems facing Rails adoption is the growing “green field” perception, i.e. – that Rails is only good for brand-new applications…. An Excerpt from a Real-Life Conversation : David Keener: I’d like to promote Rails as a tool to get  more done with fewer people. Executive: Well, it was my understanding that Rails was only good for “green field”  applications.
Summary Rails can be a good technology for corporate apps, not just “green field” apps Yes, legacy databases are harder to deal with than Rails-oriented databases, but then that’s an issue regardless of the technology used Rails is mature enough to be a realistic technology choice for many companies Plan your Rails project; don’t just “leap”

More Related Content

PPTX
How To Avoid Database Migration Hell
PPTX
Oracle SQL Developer Top 10 Tips & Tricks
PPTX
Oracle REST Data Services: POUG Edition
PPTX
Oracle SQL Developer Tips & Tricks
PPTX
Skillwise-Spring framework 1
PPTX
Oracle APEX URLs Untangled & SEOptimized
PPTX
RESTful Services for your Oracle Autonomous Database
PDF
Ant tutorial
How To Avoid Database Migration Hell
Oracle SQL Developer Top 10 Tips & Tricks
Oracle REST Data Services: POUG Edition
Oracle SQL Developer Tips & Tricks
Skillwise-Spring framework 1
Oracle APEX URLs Untangled & SEOptimized
RESTful Services for your Oracle Autonomous Database
Ant tutorial

What's hot (20)

PDF
Ten Tiny Things To Try Today - Hidden APEX5 Gems Revealed
PPTX
Abstract #236765 advanced essbase java api tips and tricks
PPTX
Oracle SQL Developer Tips and Tricks: Data Edition
PDF
Oracle SQLcl
PPTX
Plugins unplugged
PPT
SE2016 - Java EE revisits design patterns 2016
PPTX
Oracle SQL Developer: 3 Features You're Not Using But Should Be
PDF
Spring Data JPA + JSF + Maven + Mysql using Eclipse IDE
PDF
Parsing strange v4
PPTX
Oracle SQL Developer Reports
PPTX
SQLcl overview - A new Command Line Interface for Oracle Database
PPTX
Oracle SQL Developer: You're Doing it Wrong!
PPTX
Understanding and preventing sql injection attacks
PDF
High Performance PL/SQL
PPTX
Oracle Office Hours - Exposing REST services with APEX and ORDS
PPTX
Oracle SQL Developer version 4.0 New Features Overview
PPTX
Browser Developer Tools for APEX Developers
PPTX
Parsing strange v4
PDF
Satyapriya rajguru: Every day, in one way or another.
PDF
C sharp and asp.net interview questions
Ten Tiny Things To Try Today - Hidden APEX5 Gems Revealed
Abstract #236765 advanced essbase java api tips and tricks
Oracle SQL Developer Tips and Tricks: Data Edition
Oracle SQLcl
Plugins unplugged
SE2016 - Java EE revisits design patterns 2016
Oracle SQL Developer: 3 Features You're Not Using But Should Be
Spring Data JPA + JSF + Maven + Mysql using Eclipse IDE
Parsing strange v4
Oracle SQL Developer Reports
SQLcl overview - A new Command Line Interface for Oracle Database
Oracle SQL Developer: You're Doing it Wrong!
Understanding and preventing sql injection attacks
High Performance PL/SQL
Oracle Office Hours - Exposing REST services with APEX and ORDS
Oracle SQL Developer version 4.0 New Features Overview
Browser Developer Tools for APEX Developers
Parsing strange v4
Satyapriya rajguru: Every day, in one way or another.
C sharp and asp.net interview questions
Ad

Viewers also liked (20)

PPT
Университеты Англии
PPT
Entrepreneurship as a Career Choice
PDF
Pharma: Sky’s the Limit if You Have an ‘Entrepreneurial’ Mindset
PPT
HSA Drama Symbolic Capital
PPTX
Συμμετοχή του ΤΕΕ Ειδικής Αγωγής Α΄ Βαθμίδας -(Ειδικό ΕΠΑΛ Σερρών) στον Διαγω...
PPTX
How to apply for part time jobs
PPTX
Being john malkovich no vi
PDF
Συμμετοχή του 2ου ΕΠΑΛ Σερρών στον περσινό Διαγωνισμό Επιχειρηματικότητας με ...
PPT
"Strategy, tactics and staying interested."
PDF
Sept10 slides
PDF
PPT
профессиональные компетенции ппс
PDF
Web 2.0 - Social Media Emergency Management
PPTX
One 2 One Rollover
PPTX
Lecture 1: Presentation and staging msk tumour
PDF
Inaguration of Mission Year in the Diocese of Sagar
PPS
A tribute to Bishop Clemens Thottungal
PDF
Yes for eban w.u
PDF
SheSpeaks 2009 Social Media Study
PPT
CHOReOS Exploitation
Университеты Англии
Entrepreneurship as a Career Choice
Pharma: Sky’s the Limit if You Have an ‘Entrepreneurial’ Mindset
HSA Drama Symbolic Capital
Συμμετοχή του ΤΕΕ Ειδικής Αγωγής Α΄ Βαθμίδας -(Ειδικό ΕΠΑΛ Σερρών) στον Διαγω...
How to apply for part time jobs
Being john malkovich no vi
Συμμετοχή του 2ου ΕΠΑΛ Σερρών στον περσινό Διαγωνισμό Επιχειρηματικότητας με ...
"Strategy, tactics and staying interested."
Sept10 slides
профессиональные компетенции ппс
Web 2.0 - Social Media Emergency Management
One 2 One Rollover
Lecture 1: Presentation and staging msk tumour
Inaguration of Mission Year in the Diocese of Sagar
A tribute to Bishop Clemens Thottungal
Yes for eban w.u
SheSpeaks 2009 Social Media Study
CHOReOS Exploitation
Ad

Similar to Using Rails to Create an Enterprise App: A Real-Life Case Study (20)

PPT
Ruby On Rails
PDF
When To Use Ruby On Rails
PDF
Ruby on Rails Presentation
PPT
Introduction To Ruby On Rails
PDF
Extending Oracle E-Business Suite with Ruby on Rails
PDF
td_mxc_rubyrails_shin
PDF
td_mxc_rubyrails_shin
PPT
Ruby on Rails: Building Web Applications Is Fun Again!
PDF
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
PDF
Ruby on Rails in UbiSunrise
PPTX
12 Introduction to Rails
PPTX
Ruby On Rails Intro
PDF
Introduction to Ruby on Rails
DOC
4 plus years in ruby on rails
PDF
Rails - getting started
DOCX
PPT
Ruby On Rails Seminar Basis Softexpo Feb2010
PDF
Fast Web Applications Development with Ruby on Rails on Oracle
DOCX
Jacob_Shay_Resume_2016_Version_4
PDF
Ruby On Rails
Ruby On Rails
When To Use Ruby On Rails
Ruby on Rails Presentation
Introduction To Ruby On Rails
Extending Oracle E-Business Suite with Ruby on Rails
td_mxc_rubyrails_shin
td_mxc_rubyrails_shin
Ruby on Rails: Building Web Applications Is Fun Again!
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails in UbiSunrise
12 Introduction to Rails
Ruby On Rails Intro
Introduction to Ruby on Rails
4 plus years in ruby on rails
Rails - getting started
Ruby On Rails Seminar Basis Softexpo Feb2010
Fast Web Applications Development with Ruby on Rails on Oracle
Jacob_Shay_Resume_2016_Version_4
Ruby On Rails

More from David Keener (20)

PPTX
Writing Killer Fight Scenes
PPTX
Build a Space Battle
PPTX
Creating an Adaptive Setting
PDF
Public Speaking for Writers
PPTX
21st Century Writer
PPTX
Titanic: The Forgotten Passengers
PDF
Rails Tips and Best Practices
PDF
Elevator Up, Please!
PDF
Rails and the Apache SOLR Search Engine
PDF
Killer Business Models
PDF
Rails Security
PDF
Building Facebook Apps
PDF
Leveraging Rails to Build Facebook Apps
PPT
Quick Start: ActiveScaffold
PPT
Creating Custom Charts With Ruby Vector Graphics
PPT
A Tour of Ruby On Rails
PPT
Practical JRuby
PPT
Implementing OpenID for Your Social Networking Site
PDF
Creating Dynamic Charts With JFreeChart
PPT
Quick Start: Rails
Writing Killer Fight Scenes
Build a Space Battle
Creating an Adaptive Setting
Public Speaking for Writers
21st Century Writer
Titanic: The Forgotten Passengers
Rails Tips and Best Practices
Elevator Up, Please!
Rails and the Apache SOLR Search Engine
Killer Business Models
Rails Security
Building Facebook Apps
Leveraging Rails to Build Facebook Apps
Quick Start: ActiveScaffold
Creating Custom Charts With Ruby Vector Graphics
A Tour of Ruby On Rails
Practical JRuby
Implementing OpenID for Your Social Networking Site
Creating Dynamic Charts With JFreeChart
Quick Start: Rails

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
cuic standard and advanced reporting.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
KodekX | Application Modernization Development
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation theory and applications.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
The AUB Centre for AI in Media Proposal.docx
Building Integrated photovoltaic BIPV_UPV.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
“AI and Expert System Decision Support & Business Intelligence Systems”
cuic standard and advanced reporting.pdf
Electronic commerce courselecture one. Pdf
KodekX | Application Modernization Development
Programs and apps: productivity, graphics, security and other tools
Chapter 3 Spatial Domain Image Processing.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Network Security Unit 5.pdf for BCA BBA.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Empathic Computing: Creating Shared Understanding
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Review of recent advances in non-invasive hemoglobin estimation
Machine learning based COVID-19 study performance prediction
Encapsulation theory and applications.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Reach Out and Touch Someone: Haptics and Empathic Computing

Using Rails to Create an Enterprise App: A Real-Life Case Study

  • 1. Using Rails to Create an Enterprise App: A Real-Life Case Study By David Keener http://www.keenertech.com AOL proprietary information used with permission.
  • 2. Overview Multiple databases; of multiple types A Legacy database (Remedy) Significant AJAX functionality Search capability Email (or corporate spam) Ruby on Rails is clearly an exciting and ground-breaking technology. But how good is it at solving the types of problems that corporate developers need to solve? My team put Rails to the test in a real-world internal application for AOL that’s used by hundreds of employees. This case study, the Exception Request Tool , is a non-trivial application that features:
  • 3. What We Wanted to Know Does Rails really speed up development? Can it be effectively integrated with legacy databases? How hard is it to set up a Rails production environment? How hard is it to incorporate AJAX and build Web 2.0 applications? How effective is Rails at generating and sending automated emails? What pitfalls should developers watch out for? The underlying question affecting the adoption of Rails for corporate development is: “How good is it at producing web sites that aren’t blogs?”
  • 4. Rails Adoption Rails is in a unique place, just to the left of the “Chasm”. Its capacity for successful delivery of real business applications will probably be a key factor in crossing the chasm between early adopters and widespread adoption. From: Diffusion of Innovations , by E. M. Rogers, 1995
  • 5. The Case Study Application Relatively standard CRUD features, plus…. Confirm and edit capabilities for requests A search feature A history feature (for Sarbanes-Oxley support) Administrative capability to modify all aspects of a request Automated emails of various types Approval mechanism for upper management Access to legacy database (Remedy) The Exception Request Tool (ERT) allows AOL employees to request production installs for time periods when such installs are not normally allowed. Key features included:
  • 6. Database Objects Request : A request for a production install to support one or more business areas Unit : A collection of items to be installed to support a business area Install Item : Something to be installed, usually software Approver : A person who approves a unit, or a set of install items Exception Types : For metrics, categorizes aspects of each install item Exception Type Request Unit Install Item Approver
  • 7. Exception Request Tool Screenshot used with AOL permission.
  • 8. Process Change Rails facilitated delivery of an early prototype while requirements were still being drafted The prototype helped generate lots of new requirements via discussion of real screens & functionality New requirements led to major scope creep, which… Totally blew the original deadline But the customer was happier…the product was really what they wanted So the customer agreed to adopt a more “agile” approach to development going forward The first, and perhaps most striking, change due to Rails, was its impact on the development process.
  • 9. Environments Dev Environments: Easily set up on Mac & Windows Production Environment: Apache 2.2, Mongrel, Mongrel Cluster, etc. System administrators have no experience setting up Rails environments – falls to the dev team No standardization of Rails environments & recommended plug-ins – falls to the dev team At AOL: No access from prod box to outside Internet Need to allocate a non-trivial amount of time to deal with environment setup issues Applications need a place to run, where they will be properly supported. Environment set-up was not a trivial exercise.
  • 10. Database Support Rails is somewhat immature in the realm of database support, though improving Sterling support for MySQL, but other databases can be more problematic Oracle support is good Support for Sybase is pathetic – Got it working for Linux, but not for Windows and Mac If not using MySQL, need to allocate time to address database connectivity issues
  • 11. Migrations Migrations simplify database builds Database neutral A truly wonderful feature Don’t know how I lived without them Can also set up test data / lookup data class CreateRiskLookup < ActiveRecord::Migration def self.up create_table :btr_risk_lookup do |t| # t.column :name, :string t.column :risk_name, :string, :null=>false, :limit => 50 t.column :risk_desc, :string, :null=>true, :limit => 100 end end def self.down drop_table :btr_risk_lookup end end
  • 12. Cross-Database Migration Issues Migrations generally “do the right thing” across databases…but not always Oracle sequences – names too long In model: set_sequence_name shortname_idx Indices – names too long In migration: add_index :btr_install_item_exceptions, [:install_item_id, :exception_type_id], :name => 'btr_installitemex' Indices – delete in Oracle, not MySQL In migration: Needed conditional logic based on database used.
  • 13. Conditional Logic in Migrations Perform different actions based on database Only remove legacy table in MySQL (dev) Use class connection, not default Conditional logic also needed for Oracle indices def self.down adapter = User.connection.instance_variable_get(&quot;@config&quot;)[:adapter] puts(&quot;Database Adapter Detected: &quot; + adapter) if adapter == &quot;mysql“ drop_table :btr_users end end
  • 14. Killer Legacy Database Database: Sybase – Could only get access working in proposed Linux prod environment – No access from development environments Non-numeric primary keys Hundreds of database columns Read-only database access Query Performance Issues Case-sensitive column and table names! Our legacy database put Rails to the test. Our legacy database possessed the following features:
  • 15. Legacy Database Cheat Sheet Explicitly define the names of legacy tables In model: set_table_name ‘T135’ # case-sensitive in Sybase Explicitly define the name of the primary key In model: set_primary_key ‘xyz’ # case-sensitive in Sybase For tables with non-numeric keys, use SQL For tables with 100’s of columns, use SQL With query performance issues, break SQL queries into two parts: 1. Get the ID’s using whatever criteria are needed, 2. Get the subset of desired columns for just those ID’s If doing SQL, create generic methods in model; only the model should have to know about the bare-metal SQL
  • 16. Dual Query Tactic # Step 1: Get a list of matching ticket ID's res = Ticket.find_by_sql(&quot;SELECT Change_Request__ AS Change_Request&quot; + &quot; FROM CM_Change_Mgmt &quot; + &quot; WHERE Component___NUM_ LIKE '&quot; + str + &quot;%'&quot;) # Step 2: Convert result set to comma-delimited list of single-quoted ID's lst = bld_list(res) # Step 3: Get a subset of the 300+ available columns. By the way, it's # possible that multiple tickets may match tickets = Ticket.find_by_sql( &quot;SELECT CM_Change_Mgmt.Change_Request__ AS Change_Request, &quot; + &quot;CM_Change_Mgmt.Component___NUM_ AS Component, &quot; + &quot;CM_Change_Mgmt.Short_Description, &quot; + &quot;CM_Change_Mgmt.Outage_Tkt_Yes, &quot; + &quot;CM_Change_Mgmt.Outage__ AS Outage_ID, &quot; + &quot;CM_Change_Mgmt.Affects_Members_, &quot; + &quot;CM_Change_Mgmt.NUM__ AS NUMID &quot; + &quot;FROM CM_Change_Mgmt &quot; + &quot;WHERE CM_Change_Mgmt.Change_Request__ IN (&quot; + lst + &quot;) &quot; + &quot;AT isolation 0&quot;)
  • 17. JavaScript & Validations Rails supports basic JavaScript validations JavaScript takes time, requires testing to support multiple browsers, etc. JavaScript can seriously slow a project Consider custom JavaScript judiciously If JavaScript needs are intense, consider integrating other open source libraries (e.g. – Dojo or others)
  • 18. Date Manipulation Rails date manipulation features are awesome Rails date entry features are decent Really needed a popup calendar component - Also needed to be able to validate pairs of dates, i.e. – start and end dates Spent a LOT of time on date-related issues, including integrating popup calendar feature
  • 19. Popup Calendar Component Popup Calendar - Date selection - Time selection
  • 20. Email in Rails Rails includes ActionMailer class Easy-to-create email class Emails generated based on templates Easy generation of dual text/html emails Easy configuration Can have emails that mimic the web pages almost exactly Graphic incorporation more problematic Email Features: Incredible!
  • 21. Sample Email Real-Life Email - Mimics web page - Dual format
  • 22. Spaminator Model class ExceptionRequestSpaminator < ActionMailer::Base def submit(ex) email_list = @requester.email_address + &quot;,&quot; + get_email_rm subject = &quot;Exception Request #{ex.id}: SUBMITTED&quot; intro = &quot;The following exception request was just submitted. To review the request online, click <a href=#{get_local_url}/show/#{ex.id}>here</a>.&quot; setup_ERT_email(ex, subject, intro, email_list) end def setup_ERT_email(ex, subject, intro, email) @subject = subject @body = { :exception_request => ex, :request_units => ex.request_units, :requester => @requester, :intro => intro} @recipients = email @from = 'support-services-rm@listserv.sup.aol.com @sent_on = Time.now @headers = {} end end
  • 23. Sending Email Controller: To send an email… ExceptionRequestSpaminator.deliver_submit(@exception_request) Email Template – Just another “.rhtml” page - Template is “submit.text.html.rhtml” Mime Type incorporated into template name Can easily support other formats Email features – easy to implement Not so useful for social networking “green field” apps Incredibly useful for corporate enterprise apps
  • 24. Testing Rails supports extensive testing features Didn’t use ANY of them on the project Not a problem with Rails, but a major deficiency in the project Need to internalize Rails built-in testing features Should incorporate tests as one of the required outputs of each project
  • 25. Overall Rails “Report Card” – 1 A+ Prototyping: Extremely fast A Agility: Supports agile programming methodologies; not so great for waterfall, etc. A Migrations: excellent; cross-database support could be stronger A Email: Excellent; great for enterprise sites B Dates: Manipulation excellent (A); date entry is just OK (C)
  • 26. Overall Rails “Report Card” - 2 B Testing: Features are good; requires some planning; easiest thing to “drop” B Legacy DB Support: Pretty good; needs more publicity C Database Support: not consistent; still very immature C JavaScript: Supports basic validations; complex components and validations are more problematic D Environment Setup: Not widely documented; not easy for a production environment * * Note: See JRuby as an alternative environment for Rails applications.
  • 27. The “Green Field” Perception One of the biggest problems facing Rails adoption is the growing “green field” perception, i.e. – that Rails is only good for brand-new applications…. An Excerpt from a Real-Life Conversation : David Keener: I’d like to promote Rails as a tool to get more done with fewer people. Executive: Well, it was my understanding that Rails was only good for “green field” applications.
  • 28. Summary Rails can be a good technology for corporate apps, not just “green field” apps Yes, legacy databases are harder to deal with than Rails-oriented databases, but then that’s an issue regardless of the technology used Rails is mature enough to be a realistic technology choice for many companies Plan your Rails project; don’t just “leap”