# Inherited AR Methods MIssing? Errors Doesn't Exist?

**URL:** <https://www.ruby-forum.com/t/inherited-ar-methods-missing-errors-doesnt-exist/112166>\
**Category:** Rails\
**Created:** [August 16, 2007, 12:59am UTC](https://www.ruby-forum.com/t/inherited-ar-methods-missing-errors-doesnt-exist/112166 "2007-08-16T00:59:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hunter\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/bc79bd/32.png) [@hunter\_h](https://www.ruby-forum.com/u/hunter_h)\
**Post date:** [August 16, 2007, 12:59am UTC](https://www.ruby-forum.com/t/inherited-ar-methods-missing-errors-doesnt-exist/112166/1 "2007-08-16T00:59:01Z")

</div>

I’m seeing something strange and so far haven’t been able to figure  
it out. First off, here’s our setup:

MacOS X Tiger 10.4.10 (Intel)  
Ruby 1.8.6  
Rails 1.2.3  
PostgreSQL 8.2.3

I have a ton of apps that work great but a brand new app is giving me  
trouble.

I am getting an error indicating that the ‘errors’ method for the  
object doesn’t exist. It should be inherited from the base AR class.

This app has a single model, ‘Upload’ that uses attachment\_fu to take  
uploads.

Here’s my code:

Model:

class Upload \< ActiveRecord::Base  
has\_attachment :storage =\> :file\_system, :max\_size =\> 5.megabytes  
end

Controller:

def new  
@upload = Upload.new if @upload.blank?  
end

View:

\<% form\_for :upload, @upload, :url =\> {:action =\> :create} do |form| %\>  
\<% if @upload != nil && !@upload.errors.empty? -%\>  
\<%= error\_messages\_for ‘upload’ %\>  
\<% end -%\>  
\<% end %\>

The error I get is:

ActionView::TemplateError (undefined method `errors’ for #\<Upload:  
0x34e5e14\>) on line #12 of app/views/uploads/new.rhtml:

12: \<% if @upload != nil && !@upload.errors.empty? -%\>  
14: \<%= error\_messages\_for ‘upload’ %\>  
15: \<% end -%\>

```
 #{RAILS_ROOT}/app/views/uploads/new.rhtml:12:in

```

`_run_rhtml_47app47views47uploads47new46rhtml' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_view/helpers/form_helper.rb:151:in`fields\_for’  
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_view/helpers/form\_helper.rb:127:in `form_for' #{RAILS_ROOT}/app/views/uploads/new.rhtml:4:in`\_run\_rhtml\_47app47views47uploads47new46rhtml’

Huh?

When I put in some debugging code, it gets even more interesting:

I added this code to the controller:

```
 logger.debug "Upload Class: #{@upload.class}"
 logger.debug @upload.methods

```

Ok, this should tell me more. Output:

Upload Class: Upload

inspectinstance\_execlistenerclonemethodrequire\_gemrequire\_library\_or\_gem  
request\_progresspublic\_methodsencode64blank?  
listener=instance\_variable\_defined?decode64equal?  
freezeunloadableloadb64encodemethodssilence\_warningsrespond\_to?  
enable\_warningsreturningremove\_subclasses\_ofdupto\_yamlinstance\_variables  
optionsdecode\_b\_\_id\_\_object\_ideql?  
requireidprocesssilence\_streamrequest\_beginssingleton\_methodsto\_yaml\_sty  
lesendwith\_optionstaintfrozen?instance\_variable\_getgeminstance\_of?  
\_\_send\_\_to\_aextend\_with\_included\_modules\_fromrequest\_notify`typeinstance  
\_evalprotected\_methodsto\_yaml\_propertiesdisplay=====subclasses\_ofinstanc  
e\_variable\_setsilence\_stderrextended\_byextendkind\_of?  
to\_sdaemonizeinstance\_valuesclasshashto\_paramprivate\_methods=~tainted?  
suppresstagurito\_jsonuntaintnil?  
copy\_instance\_variables\_fromtaguri=dcloneis\_a?

So, it is the right class but the methods are wrong.

What the heck is going on here? When I create a new Upload object  
from the console, everything works properly and the methods are all  
there.

What gives?

Thanks,  
Hunter
