Error while using Thinking Sphinx under Ruby on Rails

雨燕双飞 提交于 2020-01-24 19:33:09

问题


Im using Thinking-Sphinx as a plugin in my RoR app, but Im having this error:

undefined method `define_index' for #

What could it be?

Model

class Group < ActiveRecord::Base
  belongs_to :retailer_product
  has_many :group_ranges, :dependent => :destroy
  has_many :group_clients, :dependent => :destroy
  has_many :group_notifications, :dependent => :destroy

  define_index do
    indexes retailer_product.review
    indexes retailer_product.retailer.retailer_name
    indexes retailer_product.product.pr_id
    indexes retailer_product.product.product_name
    indexes retailer_product.product.product_tags.tag.tag, :as => :ptag #indexes tag.tag
    indexes retailer_product.product.product_properties.property.value, :as => :pvalue #indexes product_property.value
    indexes retailer_product.product.brand.brand, :as => :product_brand

    has :id

    where "groups.active=1"

    group_by "groups.id"
  end
end

Environment.rb

# Be sure to restart your server when you modify this file

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

ENV['RAILS_RELATIVE_URL_ROOT']="/project"

Rails::Initializer.run do |config|
  config.time_zone = 'UTC'
end

Thanks in advance!


回答1:


config.gem(
  'thinking-sphinx',
  :lib     => 'thinking_sphinx',
  :version => '1.3.11'
)

Please read: http://freelancing-god.github.com/ts/en/installing_thinking_sphinx.html

restart application after editing environment.rb



来源:https://stackoverflow.com/questions/4807509/error-while-using-thinking-sphinx-under-ruby-on-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!