思考Sphinx类型与has_many关联的整数

时间:2012-03-28 13:28:04

标签: ruby-on-rails delayed-job thinking-sphinx has-many update-attribute

示例:我们有一个模型Book(标题:string desc:text)和一个模型Reader(some_integer:integer book_id:integer name:string)

class Book < ActiveRecord::Base


has_many :readers

  define_index do    
    indexes id
    indexes title      
    indexes descr
    join    readers   
    has     readers(:wert_integer), :as => :wert_integer, :sortable => true, :type => :integer
    has     readers(:first_name), :as => :first_name, :sortable => true
    has     readers(:last_name), :as => :last_name, :sortable => true
    set_property :delta => :delayed
  end
end

class Reader < ActiveRecord::Base
  belongs_to :book
end

在尝试保存图书时,我们遇到了此错误:

undefined method `wert_integer' for []:ActiveRecord::Relation

我们做错了什么?

0 个答案:

没有答案