0
當我嘗試訪問has_many關係的find方法時,出現一個非常奇怪的錯誤。使用has_many和Rails中的find()缺少方法'%'
我在做什麼語法錯誤?
# Instructor model
class Instructor < ActiveRecord::Base
has_many :events
end
# Event model
class Event < ActiveRecord::Base
belongs_to :instructor
end
# Controller snip-it
i = Instructor.first
conditions = [ :start_time => params[:start]..params[:end], :submitted => true ]
@events = i.events.find(:all, :conditions => conditions)
# Error message
# NoMethodError (undefined method `%' for {:start_time=>"1283140800".."1286769600", :submitted=>true}:Hash):
哦。謝謝。你搖滾! – Sukima 2010-09-08 00:44:59