Hi! I''m upgrading existing app from Rails 1.2.6 to 2.1.2. I have encountered following problem with AR objects. Model definition did not change and with 1.2.6: params={} params[:flight] = "1111" params[:airline] = "Air France" params[:luggage] = 0 r=Reservation.new params r.save is working code, new Reservation. With the same dataset, changing only Rails to 2.1.2 r.save returns nil, object does not get saved, nothing in log file. Using save! raises no exception. r.errors.full_messages => [] Any idea what is going on? I guess something rather strange, since save should not return nil? I''m using ruby 1.8.6-p111 on Windows, Rails 2.1.2. Tomorrow I will try to run it on some Linux with newer Ruby. I did remove all plugins - no change. Commented out all Reservation model''s validations, functions, etc. No change. What else I can try? -- Witold Rugowski Ruby on Rails freelancer http://nhw.pl/wp/ (EN blog) http://nhw.pl/pl (PL blog) --~--~---------~--~----~------------~-------~--~----~ 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 Oct 25, 12:07 am, Witold Rugowski <rugow...-kkW0WVMzbEI@public.gmane.org> wrote:> Hi! > I''m upgrading existing app from Rails 1.2.6 to 2.1.2. I have > encountered following problem with AR objects. > > Model definition did not change and with 1.2.6: > > params={} > params[:flight] = "1111" > params[:airline] = "Air France" > params[:luggage] = 0 > r=Reservation.new params > r.save > > is working code, new Reservation. With the same dataset, changing only > Rails to 2.1.2 r.save returns nil, object does not get saved, nothing > in log file. Using save! raises no exception. > > r.errors.full_messages > => [] > > Any idea what is going on? I guess something rather strange, since > save should not return nil?My guess is that you''ve accidentally overriden a function used by rails (which perhaps did not exist in rail 1.2.6). showing us your Reservation model might allow someone to confirm or infirm that idea. Fred> > I''m using ruby 1.8.6-p111 on Windows, Rails 2.1.2. Tomorrow I will try > to run it on some Linux with newer Ruby. > > I did remove all plugins - no change. Commented out all Reservation > model''s validations, functions, etc. No change. > > What else I can try? > > -- > Witold Rugowski > Ruby on Rails freelancerhttp://nhw.pl/wp/(EN blog)http://nhw.pl/pl(PL blog)--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
params={} params[:flight] = "1111" params[:airline] = "Air France" params[:luggage] = 0 r=Reservation.new params r.save params is a special hash class withindifferentaccess (whatever it means). So make sure that you Initialize that hash class rather than a ruby native hash as you are doing above. Rails adds extra methods to hash class to make it indifferent to symbol keys or string keys I believe. I have run into a large number of issues like this while upgrading a rails 1.2.6 app to rails 2.1.0 -- too many to list here. You are also doing the r.save! which is guaranteed (relatively speaking) to raise an error if not successful. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
As bharat sait do r.save! instead of r.save to view the errors raised... On Oct 25, 1:52 pm, Bharat <bcrupa...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> params={} > params[:flight] = "1111" > params[:airline] = "Air France" > params[:luggage] = 0 > r=Reservation.new params > r.save > > params is a special hash class withindifferentaccess (whatever it > means). So make sure that you Initialize that hash class rather than > a ruby native hash as you are doing above. Rails adds extra methods > to hash class to make it indifferent to symbol keys or string keys I > believe. > > I have run into a large number of issues like this while upgrading a > rails 1.2.6 app to rails 2.1.0 -- too many to list here. > > You are also doing the r.save! which is guaranteed (relatively > speaking) to raise an error if not successful.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> > My guess is that you''ve accidentally overriden a function used by > rails (which perhaps did not exist in rail 1.2.6). > showing us your Reservation model might allow someone to confirm or > infirm that idea.Yes You were right. Model Reservation had field transaction - it has overwritten http://apidock.com/rails/ActiveRecord/Transactions/transaction -- Witold Rugowski Ruby on Rails freelancer http://nhw.pl/wp/ (EN blog) http://nhw.pl/pl (PL blog) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---