Created
January 17, 2012 01:25
-
-
Save hexgnu/1623986 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expose(:current_brand) do | |
# REFACTOR THIS PLEASE :( | |
if params[:current_brand_id] | |
session[:qp_status] = nil | |
session[:qp_shared_image_ids] = nil | |
brand_id = if current_organization.brands.exists?(:id => params[:current_brand_id]) | |
session[:current_brand_id] = params[:current_brand_id] | |
params[:current_brand_id] | |
else | |
flash[:alert] = "Woops! Looks like you are trying to access something you don't have access to!" | |
current_organization.brands.first.id | |
end | |
current_organization.brands.where(:id => brand_id).first | |
elsif session[:current_brand_id] | |
current_organization.brands.where(:id => session[:current_brand_id]).first | |
else | |
if current_user.executive? | |
current_organization.brands.first | |
else | |
current_user.brands.first | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment