How to Validate
Data Input in Your
Rails App
Melissa Holmes
Rails Girls Atlanta - October 2014
in other words...
Melissa Holmes
Rails Girls Atlanta - October 2014
Let’s Validate...
Melissa Holmes
Rails Girls Atlanta - October 2014
Who am I?
Who am I?
Melissa Holmes
Who am I?
Melissa Holmes
Last year I switched from being a C++ programmer to working on web apps.
Who am I?
Melissa Holmes
Last year I switched from being a C++ programmer to working on web apps.
Currently I’m a Ruby on Rails & Sinatra developer at Rentpath.
Who am I?
Other interests:
Who am I?
Other interests:
Art/Drawing Gardening
Cats (all kinds) Knitting
Coffee & tea Reading
Validate?
Validate?
Our goal as developers:
Our goal as developers:
Don’t use or save invalid data.
Why?
The user must provide necessary and
properly formatted information needed to successfully complete an operation.
Why?
What?
Validate (a) required fields, (b) format correctness, and (c) confirmation fields.
What?
How?
Determine the expected format.
Apply appropriate rules in your code.
How?
Where?
Server-side: Model, Database
Client-side: Browser (View)
Where?
Server-side: ActiveRecord Model
Validations are written in the model’s .rb file
Server-side: ActiveRecord Model
Advantages
Server-side: ActiveRecord Model
Disadvantages
Server-side: Database
Validations are written in migrations
Server-side: Database
Advantages
Server-side: Database
Disadvantages
Client-side: Browser (HTML)
Validations are written in view files
Client-side: Browser (HTML)
Advantages
Client-side: Browser (HTML)
Disadvantages
Demo!
Demo!
Bonus Slides
Client-side: jQuery
Validations are written in javascript files
Client-side: jQuery
Advantages
Client-side: jQuery
Disadvantages
Demo!
Demo!
Questions?
Server-side Sources
Client-side Sources
Contact me!
mel_tar
meltar
meltar