Realtime index association scope

This attempts to fix the issue reported in #703

I also noticed that a `has_many :through` association with a multi attribute in the index using a pluralized name would fail the foreign key check (e.g. multi attribute called `category_ids` would not match the association foreign key of `category_id`): the second commit offers a fix for that.