Hello Everyone, I am getting following error while updating the record. i.e I have "save draft" function so I am saving data while user click "save draft" using ajax and I will change the form as update and set message id and payment id in ajax success in hidden field. so page could not load, if user click again "save draft" button i am getting following error. my params: "message"=>{"user_id"=>"90", "payment_info_attributes"=>{"id"=>"816", "first_name"=>"test", "last_name"=>"test"}, "card_type"=>"master"....... ActiveRecord::RecordNotFound (Couldn''t find PaymentInfo with ID=816 for Message with ID=89): app/controllers/messages_controller.rb:280:in `update'' message controller line 280: @message.update_attributes(params[:message]) message.rb has_one :payment_info, :as => :paymentable, :dependent => :destroy accepts_nested_attributes_for :payment_info payment_info.rb belongs_to :message Both were created and I can see that both record in my database. i.e message 89 and payment info 816 *Note*: Its working locally but in staging its not working showing below error -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d7e08369-7fa7-4b7e-bd2c-e0d6b3efcebf%40googlegroups.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
I''m a Rails noob for sure, but, you say the code you have here works in your local environment but not in a staging environment. The params hash you put here seems to have a specific ids for user, payment_info_attributes and message. I would not imagine you have the exact same data in your local environment as you do in staging. But, the error suggests a payment_info_attribute with an id of 816 and/or a messsage_id of 89 doesn''t exist. If you go into your rails console on staging and type, say, Payment.find(816) or Message.find(89) do either/both exist? From the error I''d say they simply aren''t in that database. On Wednesday, May 15, 2013 3:09:03 AM UTC-5, Saravanan P wrote:> > Hello Everyone, > > I am getting following error while updating the record. i.e I have "save > draft" function so I am saving data while user click "save draft" using > ajax and I will change the form as update and set message id and payment id > in ajax success in hidden field. so page could not load, if user click > again "save draft" button i am getting following error. > > my params: > > "message"=>{"user_id"=>"90", "payment_info_attributes"=>{"id"=>"816", > "first_name"=>"test", "last_name"=>"test"}, "card_type"=>"master"....... > > ActiveRecord::RecordNotFound (Couldn''t find PaymentInfo with ID=816 for > Message with ID=89): > app/controllers/messages_controller.rb:280:in `update'' > > message controller > line 280: @message.update_attributes(params[:message]) > > message.rb > has_one :payment_info, :as => :paymentable, :dependent => :destroy > accepts_nested_attributes_for :payment_info > > payment_info.rb > belongs_to :message > > > Both were created and I can see that both record in my database. i.e > message 89 and payment info 816 > > *Note*: Its working locally but in staging its not working showing below > error >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d542fa36-35c1-4fe2-b6db-99ac215d1167%40googlegroups.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
On May 15, 2013 3:09 AM, "Saravanan P" <saravanan.p-tks5Z7IV8F8RmelmmXo44Q@public.gmane.org> wrote:> > Hello Everyone, > > I am getting following error while updating the record. i.e I have "savedraft" function so I am saving data while user click "save draft" using ajax and I will change the form as update and set message id and payment id in ajax success in hidden field. so page could not load, if user click again "save draft" button i am getting following error.> > my params: > > "message"=>{"user_id"=>"90", "payment_info_attributes"=>{"id"=>"816","first_name"=>"test", "last_name"=>"test"}, "card_type"=>"master".......> > ActiveRecord::RecordNotFound (Couldn''t find PaymentInfo with ID=816 forMessage with ID=89):> app/controllers/messages_controller.rb:280:in `update'' > > message controller > line 280: @message.update_attributes(params[:message]) > > message.rb > has_one :payment_info, :as => :paymentable, :dependent => :destroy > accepts_nested_attributes_for :payment_info > > payment_info.rb > belongs_to :message > > > Both were created and I can see that both record in my database. i.emessage 89 and payment info 816 Do you use the same database in staging that you use locally?> > Note: Its working locally but in staging its not working showing belowerror> > -- > You received this message because you are subscribed to the Google Groups"Ruby on Rails: Talk" group.> To unsubscribe from this group and stop receiving emails from it, send anemail to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visithttps://groups.google.com/d/msgid/rubyonrails-talk/d7e08369-7fa7-4b7e-bd2c-e0d6b3efcebf%40googlegroups.com?hl=en-US .> For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Hi Guys I think I find the solution. Thanks for the reply. Thats because my old data in nested form table(payment info). Early I empty the Message table and forget to empty PaymentInfo table. In my staging console i enter Message.find(89).payment_info, it bring wrong record instead of 816 payment record. Now i deleted old data and look like working... I dont know this is error. On Thu, May 16, 2013 at 11:23 AM, tamouse mailing lists < tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On May 15, 2013 3:09 AM, "Saravanan P" <saravanan.p-tks5Z7IV8F8RmelmmXo44Q@public.gmane.org> wrote: > > > > Hello Everyone, > > > > I am getting following error while updating the record. i.e I have "save > draft" function so I am saving data while user click "save draft" using > ajax and I will change the form as update and set message id and payment id > in ajax success in hidden field. so page could not load, if user click > again "save draft" button i am getting following error. > > > > my params: > > > > "message"=>{"user_id"=>"90", "payment_info_attributes"=>{"id"=>"816", > "first_name"=>"test", "last_name"=>"test"}, "card_type"=>"master"....... > > > > ActiveRecord::RecordNotFound (Couldn''t find PaymentInfo with ID=816 for > Message with ID=89): > > app/controllers/messages_controller.rb:280:in `update'' > > > > message controller > > line 280: @message.update_attributes(params[:message]) > > > > message.rb > > has_one :payment_info, :as => :paymentable, :dependent => :destroy > > accepts_nested_attributes_for :payment_info > > > > payment_info.rb > > belongs_to :message > > > > > > Both were created and I can see that both record in my database. i.e > message 89 and payment info 816 > > Do you use the same database in staging that you use locally? > > > > > Note: Its working locally but in staging its not working showing below > error > > > > -- > > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/d7e08369-7fa7-4b7e-bd2c-e0d6b3efcebf%40googlegroups.com?hl=en-US > . > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Best Regards, *Saravanan P* * * ROR Web Developer Mobile: +919790765386 Email: psaravanan11-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.