This project is archived and is in readonly mode.

#378 ✓invalid
Mohsin

ActiveRecord Association problem

Reported by Mohsin | June 9th, 2008 @ 04:21 PM

Consider following class:

class Entity < ActiveRecord::Base

end

class Instance < ActiveRecord::Base

belongs_to :entity

end

Now somewhere in code, under development and test modes, this statemet

instance = Instance.find 100

  1. raises exception

e = instance.entity

Raises following exception (along with stack trace):

=============================================================

NoMethodError (undefined method `entity' for #):

/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:205:in `method_missing'

/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:125:in `send'

/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:125:in `method_missing'

/app/controllers/file_attachments_controller.rb:39:in `download'

/vendor/rails/actionpack/lib/action_controller/base.rb:1158:in `send'

/vendor/rails/actionpack/lib/action_controller/base.rb:1158:in `perform_action_without_filters'

/vendor/rails/actionpack/lib/action_controller/filters.rb:697:in `call_filters'

/vendor/rails/actionpack/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'

/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'

/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'

/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'

/vendor/rails/actionpack/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'

/vendor/rails/actionpack/lib/action_controller/caching.rb:678:in `perform_action'

/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'

/vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'

/vendor/rails/actionpack/lib/action_controller/caching.rb:677:in `perform_action'

/vendor/rails/actionpack/lib/action_controller/base.rb:524:in `send'

/vendor/rails/actionpack/lib/action_controller/base.rb:524:in `process_without_filters'

/vendor/rails/actionpack/lib/action_controller/filters.rb:685:in `process_without_session_management_support'

/vendor/rails/actionpack/lib/action_controller/session_management.rb:123:in `process'

/vendor/rails/actionpack/lib/action_controller/base.rb:388:in `process'

/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:171:in `handle_request'

/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:115:in `dispatch'

/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'

/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:9:in `dispatch'

/vendor/rails/railties/lib/webrick_server.rb:112:in `handle_dispatch'

/vendor/rails/railties/lib/webrick_server.rb:78:in `service'

/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'

/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'

/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'

/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'

/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'

/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'

/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'

/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'

/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'

/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'

/vendor/rails/railties/lib/webrick_server.rb:62:in `dispatch'

/vendor/rails/railties/lib/commands/servers/webrick.rb:66

/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'

/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

/vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in `require'

/vendor/rails/activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'

/vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in `require'

/vendor/rails/railties/lib/commands/server.rb:39

script/server:3:in `require'

script/server:3

=============================================================

This also happens in console. We are running on Ubuntu, Postgres 8.2

We are not able to detect why this happens as its not the case everywhere.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages