Sha256: cfca2091eb2a6a7ec69896a4174ccb17b74c74cae0ce45eeb470da48384bf037
Contents?: true
Size: 1.54 KB
Versions: 38
Compression:
Stored size: 1.54 KB
Contents
module IuguSDK module Controllers module Helpers extend ActiveSupport::Concern def search_user_account( account_id ) return false unless signed_in? and current_user current_user.account_users.where( :account_id => account_id ).try(:first) end def current_user_account @current_user_account ||= search_user_account( session[:current_account_id] ) end def current_account current_user_account.try(:account) end def set_account( resource, account_id=nil ) if account_id == nil account_id = cookies[:last_used_account_id] if cookies[:last_used_account_id] end selected_account = resource.default_account( account_id ) if selected_account cookies[:last_used_account_id] = { :value => selected_account.id, :expires => 365.days.from_now } session[ :current_account_id ] = selected_account.id end selected_account end def is_active?(control, action="", id="") if id == "" if action == "" return true if controller_name == control.gsub("/", "") else return true if controller_name == control.gsub("/", "") && action_name == action end else return true if controller_name == control.gsub("/", "") && action_name == action && id == params[:id] end return false end def body_classes [controller_name,action_name,'page-' + controller_name + '-' + action_name] end end end end
Version data entries
38 entries across 38 versions & 1 rubygems