I want to pick companies that are owned. I tried multiple combinations, new, rails 3, old school,... all of which are throwing the same syntax error unexpected \'
unexpected '\n', expecting =>
You need to switch the order of scope
with options
# File activerecord/lib/active_record/associations.rb, line 1514
def belongs_to(name, scope = nil, options = {})
reflection = Builder::BelongsTo.build(self, name, scope, options)
Reflection.add_reflection self, name, reflection
end
As you can see, the scope
should be the second parameter and options
should be the third parameter.
This should work
belongs_to :from, -> { where owned: true }, class_name: 'Company', foreign_key: 'from_id'