Skip to content

Instantly share code, notes, and snippets.

@sukima
Created September 7, 2010 21:57
Show Gist options
  • Save sukima/569211 to your computer and use it in GitHub Desktop.
Save sukima/569211 to your computer and use it in GitHub Desktop.
Confussing has_many conditional error
# 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):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment