1

10 進数または日付フィールドでどのように並べ替えますか?

class CreateUserPrices < ActiveRecord::Migration

  def self.up
    create_table :user_prices do |t|
      t.decimal :price, :precision => 8, :scale => 2
      t.date :purchase_date
      t.timestamps
    end
  end
end

ユーザー価格を価格と購入日で並べ替えようとしています。


searchable do
  text :product_name do
    product.name
  end
  # field for :price?
  # field for :purchase_date?
end

モデルには何が入りますか?

4

1 に答える 1

0

searchable doブロックに新しいコードを追加するときは、rake sunspot:reindex.

decimalフィールドはfloatを使用し、dateフィールドはtimeを使用します

searchable do
  text :product_name do
    product.name
  end
  time :purchase_date
  float :price
end
于 2011-11-20T12:04:41.333 に答える