ruby-on-rails-3activerecord

adding a scope to an _ids Active Record attribute


I have a Location that has_many Item class. items have a scope for is_enabled. I can do

loc=Location.find(1)
loc.items.is_enabled
# and
loc.item_ids

# how would I do?
loc.item_ids.is_enabled

thx


Solution

  • Use:

    loc.items.is_enabled.map &:id