My model has a datetime attribute (Postgres) and I am attempting to create a new record via form submission in my Rails app.
The form I'm submitting contains a text_field for that datetime attribute. It submits the datetime in the below format as a param:
"expires"=>"07/17/2013 12:35:26 PM"
However, once it enters into the first line of code within the Create action of my Model...
def create
@special_deal = SpecialDeal.new(params[:special_deal])
...most of the time, @special_deal.expires will = nil
. Only rarely, does it work.
I can't figure out why this is happening. I'm guessing it has something to do with including the AM or PM within the datetime value, but Im not sure.
The params includes the expires value every time:
@_params
{"utf8"=>"✓", "authenticity_token"=>"cl1SwnHOum8d/kiGnwkDsamG5IMbmdnoeFvlY11KpKc=", "special_deal"=>{"title"=>"", "provider"=>"", "description"=>"", "deal_price"=>"", "conditions"=>"", "expires"=>"07/27/2013 14:23:59", "excerpt"=>"", "original_price"=>"", "phone_number"=>"", "street"=>"", "city"=>"", "postal_code"=>"", "state"=>"", "country"=>""}, "commit"=>"Create Special deal", "action"=>"create", "controller"=>"special_deals"}
But @special_deal does not:
@special_deal
#<SpecialDeal id: nil, man_servant_id: nil, category: "", title: "", excerpt: "", description: "", original_price: nil, deal_price: nil, provider: "", product_link: "", conditions: "", phone_number: "", street: "", city: "", postal_code: "", state: "", country: "", public: true, created_at: nil, updated_at: nil, expires: nil, image_file_name: nil, image_content_type: nil, image_file_size: nil, image_updated_at: nil>