Hi,
im trying to create an application for multiple customers, where data
shouldnt be accessible to others. So ive added a customer_id to every
db-table where it matters.
Question: How can i add a Statement to find and other sql-commands so
i just pull out the ones belong to the customer, without having to
add :customer => customer to every find query? Whats the easiest way?
a before_filter perhaps, or an overwrite of the find methods?
Perhaps Im wrong with my idea anyway
Hi, im trying to create an application for multiple customers, where data shouldnt be accessible to others. So ive added a customer_id to every db-table where it matters. Question: How can i add a Statement to find and other sql-commands so i just pull out the ones belong to the customer, without having to add :customer => customer to every find query? Whats the easiest way? a before_filter perhaps, or an overwrite of the find methods?
If you setup your associations correctly (ie customer has_many :things) then you can do
customer.things.find ...
Which is a normal find call, but which is scoped to that customer
Fred
Yes, exactly what i want to do, but is there a possibility to remove the customer at the beginning, so its more DRY?