i am trying to validate without saving use the valid? method on my object. however i keep getting the following error (that i reproduced in console) "NoMethodError for field" Any ideas ? thanks adam Loading development environment.>> p = Post.new=> #<Post:0x407b6050 @attributes={"created_on"=>nil, "subcat"=>1, "cat"=>nil, "body"=>"", "zipcode"=>0, "subject"=>"", "contactok"=>"0", "views"=>0, "user_id"=>0, "image"=>nil, "email"=>nil}, @new_record=true>>> p.valid?NoMethodError: undefined method `field'' for #<Post:0x407b6050> from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1501:in `method_missing'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:294:in `send'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:294:in `validates_each'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:293:in `each'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:293:in `validates_each'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:290:in `call'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:769:in `run_validations'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:763:in `each'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:763:in `run_validations'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:727:in `valid_without_callbacks'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:306:in `valid?'' from (irb):2>>
disregard, i left :field in my model by accident and it was complaingin on that..... sorry On 1/12/06, Adam Denenberg <straightflush@gmail.com> wrote:> i am trying to validate without saving use the valid? method on my > object. however i keep getting the following error (that i reproduced > in console) "NoMethodError for field" > > Any ideas ? > > thanks > adam > > Loading development environment. > >> p = Post.new > => #<Post:0x407b6050 @attributes={"created_on"=>nil, "subcat"=>1, > "cat"=>nil, "body"=>"", "zipcode"=>0, "subject"=>"", "contactok"=>"0", > "views"=>0, "user_id"=>0, "image"=>nil, "email"=>nil}, > @new_record=true> > >> p.valid? > NoMethodError: undefined method `field'' for #<Post:0x407b6050> > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1501:in > `method_missing'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:294:in > `send'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:294:in > `validates_each'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:293:in > `each'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:293:in > `validates_each'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:290:in > `call'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:769:in > `run_validations'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:763:in > `each'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:763:in > `run_validations'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:727:in > `valid_without_callbacks'' > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:306:in > `valid?'' > from (irb):2 > >> >
Maybe Matching Threads
- Migrating a Field to External Model
- validates* give me problems
- Problem with "can''t dump anonymous class Class"
- NoMethodError in Unit Test - Rails Newcomer
- [DEFECT] ''validates_inclusion_of'' not working as expected (couldn''t post to Trac as it gave me an error)