Module: WithRecord::Railtie::Extension
- Defined in:
- lib/with_record/railtie.rb
Instance Method Summary collapse
Instance Method Details
#with_record(record) ⇒ Object
4 5 6 |
# File 'lib/with_record/railtie.rb', line 4 def with_record(record) with_records(record) end |
#with_records(*records) ⇒ Object
8 9 10 11 12 13 14 |
# 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 |