customer_price >= my_price
を検証したいと思います。私は、次のことを試してみました:Rails 3:A <Bを検証するにはどうすればAとBの両方がモデル属性ですか?
class Product < ActiveRecord::Base
attr_accessor :my_price
validates_numericality_of :customer_price, :greater_than_or_equal_to => my_price
...
end
(。my_price
がない間customer_price
は、データベース内Products
テーブルの列です)
ここでは結果である:
NameError in ProductsController#index
undefined local variable or method `my_price' for #<Class:0x313b648>
は何ですかRails 3でこれを行う正しい方法は?あなたが特定の検証を行う必要がある
おそらくあなただけのmy_priceシンボルを作るためにコロンが必要? – hdgarrood
[Rails 3で最小/最大バリデータを実装する方法は?](http://stackoverflow.com/questions/4416278/how-to-implement-min-max-validator-in-rails-3) –