Associations are not found with STI using Rails 2.3

Shahzad Bhatti
Sun, 18 Oct 2009 19:03:24 -0000

I have recently upgraded my Rails app to 2.3. I am using STI where I
have class called BaseProfile that is extended by IndividualProfile. I
have some assocations that are defined in BaseProfile but I have been
getting errors when views reference those relationships, e.g.


undefined method `primary_user?'' for
#<IndividualProfile:0x7fcb3ecea278>
RAILS_ROOT: /home2/plexobje/rails/linktank

Application Trace | Framework Trace | Full Trace
/home/plexobje/.gems/gems/activerecord-2.3.4/lib/active_record/attribute_methods.rb:255:in
`method_missing''
/home2/plexobje/rails/linktank/app/models/individual_profile.rb:32:in
`latest_event''
/home/plexobje/.gems/gems/activerecord-2.3.4/lib/active_record/associations/association_proxy.rb:221:in
`send''
/home/plexobje/.gems/gems/activerecord-2.3.4/lib/active_record/associations/association_proxy.rb:221:in
`method_missing''
/home2/plexobje/rails/linktank/app/controllers/application_controller.rb:99:in
`get_upcoming_rsvp''
/home/plexobje/.gems/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:178:in
`send''
/home/plexobje/.gems/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:178:in
`evaluate_method''
/home/plexobje/.gems/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:166:in
`call''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/filters.rb:225:in
`call''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/filters.rb:629:in
`run_before_filters''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/filters.rb:615:in
`call_filters''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue''
/home/plexobje/.gems/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in
`ms''
/home/plexobje/.gems/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:10:in
`realtime''
/home/plexobje/.gems/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in
`ms''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/rescue.rb:160:in
`perform_action_without_flash''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/flash.rb:146:in
`perform_action''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in
`send''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in
`process_without_filters''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/filters.rb:606:in
`process''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/base.rb:391:in
`process''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/base.rb:386:in
`call''
/home/plexobje/.gems/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:437:in
`call''

The primary_user? is defined in parent class. This code used to work
with older version of Rails. Is there a fix for this?
Thanks.
--
Posted via http://www.ruby-forum.com/.