Skip to content

Instantly share code, notes, and snippets.

@radar
Created May 31, 2012 22:28
Show Gist options
  • Select an option

  • Save radar/2846774 to your computer and use it in GitHub Desktop.

Select an option

Save radar/2846774 to your computer and use it in GitHub Desktop.
# current_account.time_blocks.recently_updated
# result -> lots of records
# current_account.appointments.recently_updated
# result -> NoMethodError Exception: undefined method `recently_updated' for #<Class:0x007fe6a7a13ef8>
class Appointment < ActiveRecord::Base
belongs_to :time_block
scope :recently_updated, includes(:time_block).where("time_blocks.updated_at > ?", 5.days.ago).order("time_blocks.updated_at desc").limit(50)
end
class TimeBlock < ActiveRecord::Base
has_one :appointment
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment