Forum: Ruby on Rails validating without saving

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 Adam Denenberg (Guest)
on 2006-01-13 05:25
(Received via mailing list)
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
F15fdc7cb2e911b3808837f2be244add?d=identicon&s=25 Adam Denenberg (Guest)
on 2006-01-13 05:28
(Received via mailing list)
disregard, i left :field in my model by accident and it was
complaingin on that.....

sorry
This topic is locked and can not be replied to.