Updating the quiries to execute in context of respective company and updating code according to rails 4.0