在 Ruby on Rails 下使用 Thinking Sphinx 时出错

发布于 2024-10-14 02:59:41 字数 1440 浏览 4 评论 0原文

我在我的 RoR 应用程序中使用 Thinking-Sphinx 作为插件,但出现以下错误:

未定义方法 `define_index' for #

它可能是什么?

模型

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

环境.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

提前致谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

揽月 2024-10-21 02:59:41
config.gem(
  'thinking-sphinx',
  :lib     => 'thinking_sphinx',
  :version => '1.3.11'
)

请阅读:
http://freelancing-god.github.com/ts/en/installing_thinking_sphinx.html

编辑environment.rb后重新启动应用程序

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文