Refinery中的未定义方法::启用搜索时的博客

时间:2014-02-07 07:17:35

标签: ruby-on-rails ruby-on-rails-3 plugins refinerycms

我在Gemfile中启用了Refinery Search和Refinery博客扩展,并运行rake db:migraterake db:seed

根据Refinery Search说明文件,将以下内容添加到config/application.rb

 config.to_prepare do
   Refinery.searchable_models = [Refinery::Blog]
 end

还使用

创建了app/decorators/models/refinery/blog_decorator.rb
 Refinery::Blog.class_eval do
   acts_as_indexed :fields => [:title, :body, :custom_teaser]
 end

以上示例来自:http://refinerycms.com/guides/extending-model

但是当我尝试运行rails crails s时,会出现错误:

=> Ctrl-C to shutdown server
Exiting
/home/bismailov/Desktop/my_docs/Inbox/ror/maqolarefinery/app/decorators/models/refinery/blog_decorator.rb:2:in `block in <top (required)>': 
undefined method `acts_as_indexed' for Refinery::Blog:Module (NoMethodError)
    from /home/bismailov/Desktop/my_docs/Inbox/ror/maqolarefinery/app/decorators/models/refinery/blog_decorator.rb:1:in `class_eval'

我在这里可以缺少什么?非常感谢你!

1 个答案:

答案 0 :(得分:0)

实际上Refinery::Blog是一个模块而不是模型。理想情况下,您应该使用Refinery::Blog::Post