In my application, I have Company, Division, Users.... Company - have many Divisions, Users - belongs to one or more Divisions.
When user login, the current_division is set to User.division[0] in the Application_controller. I want to implement a feature where user can switch between different divisions. Any ideas about how to implement this functionality.
How to change current_division in the Application_controller? This current_division is used by other controllers and models.
Class Division < ActiveRecord:Base
def self.current_div options={}
if options[:division_id].nil?
current_user.division[0]
else
Division.find_by_id(options[:id])
end
end
I call Division.current_div method when user choose a different division from dropdown