I have a weird problem going on. All of sudden, records for a certain model will not save with #save Please take a look at this:>> p = Payment.new(:payment_reason_id => 1, :payment_method_id => 1, :date => Date.today, :amount => ''5.00'', :payable => Student.find(608))=> #<Payment id: nil, school_id: nil, payment_reason_id: 1, payment_method_id: 1, date: "2008-05-25", amount: #<BigDecimal: 46958f8,''0.5E1'',4(8)>, created_at: nil, updated_at: nil, invoice_id: nil, creator: nil, check_number: nil, payable_type: "Student", payable_id: 608>>> p.valid?=> false>> p.school_id = 1 # school_id is attr_protected=> 1>> p.valid?=> true>> p.save=> nil>> p.save!=> nil>> p.save_with_validation=> true Why is save returning nil? Why is save_with_validation working? I have a Tuition model that is very similar to the Payment model and it does not have this problem. Please help. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-25 11:16 UTC
Re: record will absolutely not save! so weird, please help.
On May 25, 12:07 pm, jko170 <jko...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a weird problem going on. All of sudden, records for a certain > model will not save with #save Please take a look at this: >Does your model have a method or association called transaction ? Fred> >> p = Payment.new(:payment_reason_id => 1, :payment_method_id => 1, :date => Date.today, :amount => ''5.00'', :payable => Student.find(608)) > > => #<Payment id: nil, school_id: nil, payment_reason_id: 1, > payment_method_id: 1, date: "2008-05-25", amount: #<BigDecimal: > 46958f8,''0.5E1'',4(8)>, created_at: nil, updated_at: nil, invoice_id: > nil, creator: nil, check_number: nil, payable_type: "Student", > payable_id: 608>>> p.valid? > => false > >> p.school_id = 1 # school_id is attr_protected > => 1 > >> p.valid? > => true > >> p.save > => nil > >> p.save! > => nil > >> p.save_with_validation > > => true > > Why is save returning nil? Why is save_with_validation working? > > I have a Tuition model that is very similar to the Payment model and > it does not have this problem. Please help.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Wow Frederick I feel like an idiot! That completely skipped my mind because I have a has_many :transactions on another model and of course that doesn''t cause complications. Thanks for the help! On May 25, 6:16 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On May 25, 12:07 pm, jko170 <jko...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a weird problem going on. All of sudden, records for a certain > > model will not save with #save Please take a look at this: > > Does your model have a method or association called transaction ? > > Fred > > > >> p = Payment.new(:payment_reason_id => 1, :payment_method_id => 1, :date => Date.today, :amount => ''5.00'', :payable => Student.find(608)) > > > => #<Payment id: nil, school_id: nil, payment_reason_id: 1, > > payment_method_id: 1, date: "2008-05-25", amount: #<BigDecimal: > > 46958f8,''0.5E1'',4(8)>, created_at: nil, updated_at: nil, invoice_id: > > nil, creator: nil, check_number: nil, payable_type: "Student", > > payable_id: 608>>> p.valid? > > => false > > >> p.school_id = 1 # school_id is attr_protected > > => 1 > > >> p.valid? > > => true > > >> p.save > > => nil > > >> p.save! > > => nil > > >> p.save_with_validation > > > => true > > > Why is save returning nil? Why is save_with_validation working? > > > I have a Tuition model that is very similar to the Payment model and > > it does not have this problem. Please help.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---