In one app (Beast app example) the User class has a login validation : validates_length_of :login, :minimum => 2 the users table has been created .. with one record login ''kadoudal'' create_table "users", :force => true do |t| t.column "login", :string t.column "email", :string I check with script/console => >> User.find(:first) and I get the user #<User:0x34e5e54 @attributes={"login"=>"kadoudal" ....... ----- In my app I replicated the User class ( copied exactly same code) I copied the ''users'' table into my DB and the schema.db is exactly the same... I check with script/console => >> User.find(:first) and I got an error !! NoMethodError: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.% from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/validations.rb:487:in `validates_size_of'' from /usr/local/lib/ruby/gems/1.8/gems/gettext-1.9.0/lib/gettext/active_record.rb:85:in `validates_length_of'' from ./script/../config/../config/../app/models/user.rb:6 from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:203:in `load_file'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:342:in `new_constants_in'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:202:in `load_file'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:94:in `require_or_load'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:248:in `load_missing_constant'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:452:in `const_missing'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:464:in `const_missing'' from (irb):1 and the line 6 in models/user.rb is ... validates_length_of :login, :minimum => 2 where could be the origin of such different behavior ? (...) thanks for your suggestions kad -- 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 -~----------~----~----~----~------~----~------~--~---
Kad Kerforn wrote:> NoMethodError: You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.% > from > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/validations.rb:487:in > `validates_size_of'' > from > /usr/local/lib/ruby/gems/1.8/gems/gettext-1.9.0/lib/gettext/active_record.rb:85:in > `validates_length_of'' > from ./script/../config/../config/../app/models/user.rb:6 > fromA guess: it has something to do with the validation message. Go check out active_record/validations.rb:487, where your error is occurring. You''ll see that the error is from calling % on an apparently nil string. Are you sure you''re not passing an invalid :message or :too_short in the options hash? Or perhaps, as the next level of the stack suggests, GetText is messing around with it? Try disabling GetText temporarily. If you can''t figure it out, post more of your model so we can see what''s going on. Chris Kampmeier http://kampers.net -- 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 -~----------~----~----~----~------~----~------~--~---
Chris Kampmeier wrote:> Kad Kerforn wrote: >> NoMethodError: You have a nil object when you didn''t expect it! >> The error occurred while evaluating nil.% >> from >> /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/validations.rb:487:in >> `validates_size_of'' >> from >> /usr/local/lib/ruby/gems/1.8/gems/gettext-1.9.0/lib/gettext/active_record.rb:85:in >> `validates_length_of'' >> from ./script/../config/../config/../app/models/user.rb:6 >> from > > A guess: it has something to do with the validation message. Go check > out active_record/validations.rb:487, where your error is occurring. > You''ll see that the error is from calling % on an apparently nil string. > Are you sure you''re not passing an invalid :message or :too_short in the > options hash? Or perhaps, as the next level of the stack suggests, > GetText is messing around with it? > > Try disabling GetText temporarily. If you can''t figure it out, post more > of your model so we can see what''s going on. > > Chris Kampmeier > http://kampers.netThanks Chris Very strange... I modified the config/environments/development.rb (as per the beast example, mine was different...) => config.cache_classes = true and it runs ok ... now figuring why is another step ..... -- 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 -~----------~----~----~----~------~----~------~--~---