module WithRecord::Railtie::Extension

Public Instance Methods

with_record(record) click to toggle source
# File lib/with_record/railtie.rb, line 4
def with_record(record)
  with_records(record)
end
with_records(*records) click to toggle source
# File lib/with_record/railtie.rb, line 8
def with_records(*records)
  pk         = @klass.primary_key
  record_ids = Array.wrap(records).flatten.compact.collect do |e|
    (e.is_a?(Integer) || e.is_a?(String)) ? e : e.send(pk)      
  end
  @klass.unscoped.where(pk => (self.pluck(pk) + record_ids))
end