strong_parameters in Rails using datetime

Asked

Viewed 66 times

3

I’m using strong_parameters to create an object nested in a form. All my attributes work correctly, except those defined in datetime.

There’s something special about getting datetime nestled?

Looking at the console, the attribute is being nested correctly, but it comes with the specification of Ni, with N from 1 to 6 depending on which parameter it refers to (year, month, day...), but when creating the object (INSERT INTO), the attribute specified in datetime does not appear:

Processing by ReleasesController#create as HTML
Parameters: {"utf8"=>"✓", ... "release"=>{ ... "qm_attributes"=>{"user_id"=>"1", "start_at(1i)"=>"2014", "start_at(2i)"=>"3", "start_at(3i)"=>"31", "start_at(4i)"=>"14", "start_at(5i)"=>"57", "end_at(1i)"=>"2014", "end_at(2i)"=>"3", "end_at(3i)"=>"31", "end_at(4i)"=>"14", "end_at(5i)"=>"57", ... }}, "commit"=>"Create Release"}

SQL (0.3ms)  INSERT INTO "qms" ("created_at", "release_id", "tipo_qm_release", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?)

1 answer

2


I found out that the datetime_selector html does not work for objects nested to the form. When I passed the date by text, everything worked correctly, doing the correct parse for datetime. If anyone has questions about the entire process of using strong_parameters, can be more specific.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.