Heinz Strunk
2010-Aug-22 18:51 UTC
Rails 3: Error saving an object with no useful information
Hey, I''m kinda desperate cause I''m getting an error and have no idea how to fix this since it doesn''t give me any information hinting where the problem is: irb(main):054:0> reload!;User.last.save! Reloading... NameError: undefined local variable or method `to_ary'' for #<User:0x4ed5d20> from D:/ruby192/lib/ruby/gems/1.9.1/gems/activemodel-3.0.0.rc/lib/active_model/attribute_methods.rb:364:in `method_missing'' from D:/ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.0.rc/lib/active_record/attribute_methods.rb:46:in `method_missing'' from D:/ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.0.rc/lib/active_record/connection_adapters/abstract/database_statements.rb:296:in `flatten'' from D:/ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.0.rc/lib/active_record/connection_adapters/abstract/database_statements.rb:296:in `rollback_transaction_records'' from D:/ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.0.rc/lib/active_record/connection_adapters/abstract/database_statements.rb:177:in`rescue in transaction'' from D:/ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.0.rc/lib/active_record/connection_adapters/abstract/database_statements.rb:162:in`transaction'' from D:/ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.0.rc/lib/active_record/transactions.rb:204:in `transaction'' from D:/ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.0.rc/lib/active_record/transactions.rb:287:in `with_transaction_returning_status'' from D:/ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.0.rc/lib/active_record/transactions.rb:242:in `save!'' from (irb):54 from D:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0.rc/lib/rails/commands/console.rb:44:in `start'' from D:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0.rc/lib/rails/commands/console.rb:8:in `start'' from D:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0.rc/lib/rails/commands.rb:23:in `<top (required)>'' from script/rails:6:in `require'' from script/rails:6:in `<main>'' Is it possible to show more debug information or something like that? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Heinz Strunk
2010-Aug-23 07:32 UTC
Re: Rails 3: Error saving an object with no useful information
No one? I''m kinda desperate with that problem... -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Are you working from irb or the console? It seems that you are running your code from irb (irb(main):054:0> reload!;User.last.save!) and you might not have everything you need loaded. I just tried User.last.save! from the console on one of my apps and it works just fine. On Aug 23, 3:32 am, Heinz Strunk <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> No one? I''m kinda desperate with that problem... > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Sorry, I didn''t pay too much attention to the subject. My apps run under 2.3.5 and that might make things different, though. On Aug 23, 3:32 am, Heinz Strunk <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> No one? I''m kinda desperate with that problem... > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Heinz Strunk
2010-Aug-23 16:04 UTC
Re: Rails 3: Error saving an object with no useful information
I''m using console and I restarted and reloaded it a couple of times. Rails 3.0.0.rc and Ruby 1.9.2 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker
2010-Aug-23 16:25 UTC
Re: Rails 3: Error saving an object with no useful information
Heinz Strunk wrote:> irb(main):054:0> reload!;User.last.save! > Reloading... > NameError: undefined local variable or method `to_ary'' for > #<User:0x4ed5d20> > from > D:/ruby192/lib/ruby/gems/1.9.1/gems/activemodel-3.0.0.rc/lib/active_model/attribute_methods.rb:364:in > `method_missing''What is ''to_ary'' supposed to be? Is that a method you added to User? User appears to be an ActiveRecord::Base subclass and ''to_ary'' is making it into ActiveRecord''s implementation of method_missing, which apparently doesn''t know what to do with the method with that name. At least that''s what I can glean from the stack trace. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I know it''s silly but have you checked the log file(s)? If you are working with the console in development mode it should give you all information you might need to debug the problem. Thinking about the problem a little more makes me believe that you probably have code that looks like this: u = User.find your_id_value # => Will produce a User object u.to_ary # => This gives you an error When you run to_ary against a user object you get an error but when you run it against an array of users it works: u = User.find :all # => Will produce an array of User objects u.to_ary # => This works On Aug 23, 12:04 pm, Heinz Strunk <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''m using console and I restarted and reloaded it a couple of times. > > Rails 3.0.0.rc and Ruby 1.9.2 > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Heinz Strunk
2010-Aug-24 16:16 UTC
Re: Rails 3: Error saving an object with no useful information
No, exactly that is the problem. I never used .to_ary in my code. Where can I see the debug log of the console? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.