views:

44

answers:

1

I'm having trouble in my application where a controller is calling a method and the server is reporting that the method doesn't exist.

This is the method call. The method not working is tag.related_tags

@related_tags = @tags.collect { |tag| tag.related_tags }.flatten.uniq

The Tag model is originally defined in an plugin acts-as-taggable-on. It is then extended inside of the plugin that contains it, community_engine. Then finally it is extended again in my app directory. The method related_tags is located inside of the community_engine plugin's tag.rb file.

Edits:
Here is the error message

undefined method `related_tags' for #<ActsAsTaggableOn::Tag id: 26, name: "sql">

And the stack trace

c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/attribute_methods.rb:260:in `method_missing'
c:/Users/Teddy/railCode/careercup/app/controllers/tags_controller.rb:80:in `show'
c:/Users/Teddy/railCode/careercup/app/controllers/tags_controller.rb:80:in `collect'
c:/Users/Teddy/railCode/careercup/app/controllers/tags_controller.rb:80:in `show'
+1  A: 

Looking at the code of the two plugins you mention I don't think the model hierarchy works how you expect. The CommunityEngine Tag model does not extend ActsAsTaggableOn::Tag. So, the Tag objects you're working with do not have a related_tags method defined.

Sugerman
Inside of the CommunityEngine Tag I put `require_dependency File.dirname(__FILE__) + '/../../plugins/acts_as_taggable_on/lib/acts_as_taggable_on/tag.rb'`I'm also using the plugin desert which if I understand correctly, takes care of extending the models.
Teddy