Mysql2::Error: Incorrect date value: '--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess -


i moved sqllite mysql (recreated same workspace mysql right beginning. did not migrations).

the code worked sqllite erroring out mysql. how database.yml looks like:

development:   adapter: mysql2   database: dev   username: root   password:    host: localhost   pool: 5 

my code takes in date through date select in view:

<%= date_select(:dob, nil, :use_short_month => true, :start_year => time.now.year - 100,                        :end_year => time.now.year, :order => [:day, :month, :year]) %> 

the model looks this:

t.string   "firstname" t.string   "lastname" t.string   "email" t.string   "password" t.date     "dob" 

but insert through following code in controller fails:

@user.dob = params[:dob] 

this error get:

mysql2::error: incorrect date value: '--- !ruby/hash:activesupport::hashwithindifferentaccess (1i): '2013' (2i): '4' (3i): '18' ' column 'dob' @ row 1: insert `users` (`email`, `created_at`, `dob`, `firstname`, `lastname`, `password`, `personalemail`, `updated_at`) values ('abc@xyz.com', '2013-04-18 15:46:26', '--- !ruby/hash:activesupport::hashwithindifferentaccess\n(1i): \'2013\'\n(2i): \'4\'\n(3i): \'18\'\n', 'abc', 'xyz', 22, null, 'ab4d8d2a5f480a137067da17100271cd176607a1', '2013-04-18 15:46:26') 

i had googled quite extent couldnt find references this. appreciate leads or on this.

the problem multiparameter thing. rails date_select helper generates 3 dropdowns pass 3 different parameters controller. if use mass assignment in controller, rails magically converts these 3 values 1 date value. (quite old) blog post shows way without mass-assignment: http://www.springenwerk.com/2008/05/set-date-attribute-from-dateselect.html but, post rather old, , there could(!) better way now


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -