Skip to content

Instantly share code, notes, and snippets.

View tspore's full-sized avatar

Tony Spore tspore

View GitHub Profile
@tspore
tspore / rspec model test
Created November 13, 2011 22:51
getting params into my model test
**************
Inbound params from a third party
**************
# params => {"unit_id"=>"4eb2204eed964930f4000049", "final_outputs"=>[{"birth_day"=>[""], "birth_month"=>[""], "birth_year"=>["1913"], "death_day"=>[""], "death_month"=>[""], "death_year"=>["1999"], "first_name"=>["Gladys"], "gender"=>["female"], "max_no"=>"", "middle_name"=>["Opal"], "military_service"=>[""], "not_readable"=>"", "number"=>"", "rotated"=>"", "suffix"=>[""], "surname"=>["Abbott"], "veteran"=>["no"], "eulogy"=>["Beloved Mother and Wife"], "id"=>"4eb36ff117c0dd5bd5000003"}], "meta_data"=>"16585"}
*************
Controller -
*************
def create
# "name"
# "description"
# "color"
# "size"
# "created_at"
# "updated_at"
# "box_id"
class Widget < ActiveRecord::Base
before_validation :normalize_color