1
我试图在我的rails应用程序中实现全文搜索。该应用程序基于comfortable_mexican_sofa。全文我使用sunspot gem。我需要添加可搜索的属性到Pages类。我在具有相同类的模型下创建了一个新文件,但似乎没有工作。我怎样才能扩展这个类?我收到错误在comfortable_mexican_matress中扩展模型
`undefined method `search' for #<Class:0x007fbe90f6faa8>`
应用程序/模型/ Page.rb
class Comfy::Cms::Page < ActiveRecord::Base
searchable do
text :label, :content_cache
boolean :featured
end
end
articles_controller.rb
def index
since = params[:sinceDate]
query = params[:searchQuery]
@articles = nil
if query
@articles = Comfy::Cms::Page.search{ fulltext query }.published.all
else
@articles = Comfy::Cms::Page.published.all
end
if since
@articles = @articles.reject{ |a| a[:created_at] < Date.parse(since) }
end
# @articles
# if query
# @articles = @articles.select{ |a| a[:label].match(/#{query}/i) }
# end
end