Why doesnt this work..it''s not setting my paid_until_date. VIEW CODE Paid until <%= date_select ''property'', ''paid_until_date'', :order => [:day, :month, :year] %> CONTROLLER ACTION def record_payment @property = Property.find(params[:id]) Property.find(params[:id]).payments.create(params[:payment]) @property.update_attribute(:paid_until_date, params[:paid_until_date]) # puts @property.property_name # redirect_to :action => ''list_all_properties'' <-- WORKS ! redirect_to :action => ''manage_payments'', :id => @property end PARAMS PASSED FROM LOG Parameters: {"commit"=>"Record Payment", "property"=>{"paid_until_date(1i)"=>"2008", "paid_until_date(2i)"=>"1", "paid_until_date(3i)"=>"12"}, "action"=>"record_payment", "id"=>"1", "payment"=>{"paid_on(1i)"=>"2008", "paid_on(2i)"=>"1", "amount"=>"22222", "note"=>"", "paid_on(3i)"=>"12"}, "controller"=>"admin"} EXTRACT OF UPDATE LINE IN LOG... Property Update (0.000624) UPDATE properties SET `property_name` ''Rupes Place'', `paid_until_date` = NULL <---- why NULL ? driving me a bit mad, any kind person help me out ? I think i am close ? bb -- 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 -~----------~----~----~----~------~----~------~--~---
any ideas? -- 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 -~----------~----~----~----~------~----~------~--~---
On 1/12/08, bingo bob <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Why doesnt this work..it''s not setting my paid_until_date. > > VIEW CODE > > Paid until <%= date_select ''property'', ''paid_until_date'', :order => > [:day, :month, :year] %> > > > CONTROLLER ACTION > > def record_payment > @property = Property.find(params[:id]) > Property.find(params[:id]).payments.create(params[:payment]) > @property.update_attribute(:paid_until_date, > params[:paid_until_date])Have a close look at those parameters you listed below. I think this last line should be @property.update_attribute(:paid_until_date, params[:property][:paid_until_date])> PARAMS PASSED FROM LOG > > Parameters: {"commit"=>"Record Payment", > "property"=>{"paid_until_date(1i)"=>"2008", "paid_until_date(2i)"=>"1", > "paid_until_date(3i)"=>"12"}, "action"=>"record_payment", "id"=>"1", > "payment"=>{"paid_on(1i)"=>"2008", "paid_on(2i)"=>"1", > "amount"=>"22222", "note"=>"", "paid_on(3i)"=>"12"}, > "controller"=>"admin"} > > > EXTRACT OF UPDATE LINE IN LOG... > > Property Update (0.000624) UPDATE properties SET `property_name` > ''Rupes Place'', `paid_until_date` = NULL <---- why NULL ? > > driving me a bit mad, any kind person help me out ? I think i am close ? > > bb > -- > Posted via http://www.ruby-forum.com/. > > > >-- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.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 -~----------~----~----~----~------~----~------~--~---
thanks but still no dice...with the new line? here are the passed params... Parameters: {"commit"=>"Record Payment", "property"=>{"paid_until_date(1i)"=>"2011", "paid_until_date(2i)"=>"1", "paid_until_date(3i)"=>"12"}, "action"=>"record_payment", "id"=>"1", "payment"=>{"paid_on(1i)"=>"2008", "paid_on(2i)"=>"1", "amount"=>"444", "note"=>"", "paid_on(3i)"=>"12"}, "controller"=>"admin"} -- 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 -~----------~----~----~----~------~----~------~--~---
stephen.celis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-12 16:04 UTC
Re: setting my paid_until_date
The passed params should be the same, as only the controller code was modified. If you notice: Parameters : { ... "property"=>{"paid_until_date(...)"=>"...", ... } } Because you''re using date_select, it splits the value into 3 and reassembles it later into params[:property][:paid_until_date] If you''d like to see what your controller is using, try adding a "puts params.inspect" or "puts params[:property].inspect". You can also try to update with: @property.update_attributes(params[:property]) On Jan 12, 8:58 am, bingo bob <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> thanks but still no dice...with the new line? > > here are the passed params... > > Parameters: {"commit"=>"Record Payment", > "property"=>{"paid_until_date(1i)"=>"2011", "paid_until_date(2i)"=>"1", > "paid_until_date(3i)"=>"12"}, "action"=>"record_payment", "id"=>"1", > "payment"=>{"paid_on(1i)"=>"2008", "paid_on(2i)"=>"1", "amount"=>"444", > "note"=>"", "paid_on(3i)"=>"12"}, "controller"=>"admin"} > > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 12, 2008, at 6:13 AM, bingo bob wrote:> def record_payment > @property = Property.find(params[:id]) > Property.find(params[:id]).payments.create(params[:payment]) > @property.update_attribute(:paid_until_date, > params[:paid_until_date])This won''t solve your problem, but why are you doing the find twice? Why not make the create line be @property.payments.create(params[:payment]) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---