date not saved

36 views
Skip to first unread message

james burrett

unread,
Jan 4, 2012, 3:08:33 PM1/4/12
to calendar_date_select
I have tried with and without params[] - no luck - date not saved.
Date currently stored in table IS displayed.
Rails 2.3.5, calendar_date select 1.16.3
Any thoughts most welcome - i'm desperate after 24 hours of
looking....

<% form_for(@sample) do |f| %>
<%= f.error_messages %>
<tr><td><%= f.label :shipping_date %></td><td><%=
f.calendar_date_select :shipping_date %></td>
..

<% @sample.shipping_date = params[:shipping_date] %>
<% @sample.tissue_type = params[:tissue_type] %>
<% @sample.collected_on_day = params[:collected_on_day] %>
<% @sample.collected_on_month = params[:collected_on_month] %>
<% @sample.collected_on_year = params[:collected_on_year] %>
<% @sample.project_id = 1%>
<tr><td><%= f.submit "Update" %></td></tr>
<% end %>

Tim Harper

unread,
Jan 4, 2012, 4:32:32 PM1/4/12
to calendar_d...@googlegroups.com
Hi James!

If I understand correctly, everything is working OK with the picker, it's just when you go to submit the form the value does not persist to the database?

Perhaps there is a problem with the date parsing logic. Have you used the ruby debugger before? In the appropriate place (your sample controller save method likely) I'd write the following line:

puts @sample.shipping_date
@sample.shipping_date = params[:sample][:shipping_date]
puts @sample.shipping_date

See if the value changes properly. If not, use the debugger to step in. Something like this would get you going:

puts @sample.shipping_date
require 'ruby-debug'; debugger
@sample.shipping_date = params[:sample][:shipping_date]
puts @sample.shipping_date

See the ruby-debug help page for commands.

If the value IS being changed properly, then something is setting it back, or the model may not be saved at all. Check to see if @sample.valid? is true… if not, look at @sample.errors

Narrowing down where the value fails to perpetuate will be most helpful.

Tim

> --
> You received this message because you are subscribed to the Google Groups "calendar_date_select" group.
> To post to this group, send email to calendar_d...@googlegroups.com.
> To unsubscribe from this group, send email to calendar_date_se...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/calendar_date_select?hl=en.
>

james burrett

unread,
Jan 4, 2012, 5:45:49 PM1/4/12
to calendar_d...@googlegroups.com
Thanks Tim !  It's fixed  !  
Your 3 lines in the controller clearly showed the value could be updated properly 

It was such a stupid error on my part. Your suggestion that perhaps it was being erased after the fact made me see another line in the view that used " text_field :shipping_date" that should not have been there. It was left over from a merge of two forms and was resetting the value.

I have tried to get the debugger running in the past without success - I will try again and perhaps try posting on IRC or in groups if I am stuck

thanks again Tim !
- James

Tim Harper

unread,
Jan 4, 2012, 6:04:51 PM1/4/12
to calendar_d...@googlegroups.com

On Jan 4, 2012, at 3:45 PM, james burrett wrote:

> Thanks Tim ! It's fixed !
> Your 3 lines in the controller clearly showed the value could be updated properly

Glad to have been of service!

>
> It was such a stupid error on my part. Your suggestion that perhaps it was being erased after the fact made me see another line in the view that used " text_field :shipping_date" that should not have been there. It was left over from a merge of two forms and was resetting the value.
>
> I have tried to get the debugger running in the past without success - I will try again and perhaps try posting on IRC or in groups if I am stuck

That's right… you're still on windows. I know many windows users use ruby-debug successfully… I remember getting it to work back when I was on windows.

May have to end up building your own ruby with mingw… cygwin may work but suffers performance wise with FS access due to cygwin filesystem layer. And… both those are probably more than your looking to do :)

You might try this: http://rubyinstaller.org/ … I'm sure they've ironed out the gems that have to compile c code.

Tim

Reply all
Reply to author
Forward
0 new messages