Hi,
I need to save a field as 0 in a table
I have set the Default value as 0, for ''number_of_days'' field
in ''tasks''
table.
I have a form which has this field.
When I set the field empty(blank field!) and save the form, it is saved
as null.
But I want this to be saved as 0.
I am using
<% remote_form_for(:task, :url => tasks_path) do |f| %>
and in ''create'' method I save as @task.save
Note:
I have an idea of explicitly assigning zero
like.....params[:task][:number_of_days]=0 if
params[:task][:number_of_days].blank?
But I want an alternative best approach without explicit assignment.
Thanks in advance..
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---