Skip to content

Instantly share code, notes, and snippets.

@shtirlic
Created October 31, 2012 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shtirlic/3990319 to your computer and use it in GitHub Desktop.
Save shtirlic/3990319 to your computer and use it in GitHub Desktop.
Dynamic condition
class Item < ActiveRecord::Base
has_many :places, conditions: Proc.new { "filter_status = #{@filter_status}"}
attr_accessor :filter_status
end
class Item < ActiveRecord::Base
has_many :places, conditions: Proc.new { "filter_status = #{@filter_status}"}
attr_reader :filter_status
def apply_filter_status(status)
@filter_status = status
self.places.reset
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment