Reputation: 356
Im having troubles using the helper time_select in my RoR app.
For example, I have a form in the app to submit recipes, in the _form.html.erb I have the following field for the time
<div class="form-group">
<%= f.label :tiempo, :class => 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.time_select :tiempo, :required => true,:class => 'form-control' %>
</div>
<%=f.error_span(:tiempo) %>
</div>
and it works, but the problem is when I try to edit the recipe, im getting the following error, for example
undefined method `min' for "{1=>2016, 2=>1, 3=>19, 4=>19, 5=>28}":String
I know that is because I'm saving a Hash as a String in my database, and when I try to edit the value, time_select is looking for a hash but not a string, the problem is Im not sure how to fix it
EDIT:
In the end, the problem was fixed chaging the "tiempo" type from string to time
Upvotes: 1
Views: 1187
Reputation: 107142
To store a date with a time, change the type of the database column to datetime
.
Upvotes: 2