【发布时间】:2010-07-29 20:24:48
【问题描述】:
我的应用程序遇到问题,其中控制器正在调用方法,而服务器报告该方法不存在。
这是方法调用。不起作用的方法是tag.related_tags
@related_tags = @tags.collect { |tag| tag.related_tags }.flatten.uniq
标签模型最初是在一个插件中定义的,即作为可标记的。然后在包含它的插件 community_engine 中扩展它。最后它在我的应用程序目录中再次扩展。方法related_tags 位于community_engine 插件的tag.rb 文件中。
编辑:
这是错误信息
undefined method `related_tags' for #<ActsAsTaggableOn::Tag id: 26, name: "sql">
还有堆栈跟踪
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'
【问题讨论】:
-
您能否粘贴显示缺少方法异常的堆栈跟踪?可能
@tags由 Array 对象组成,而不是 Tag 对象。
标签: ruby-on-rails routes ruby-on-rails-plugins acts-as-taggable-on