Sha256: e50cdc8ebac4934d5a04cc9c01bf6a5ed2eaca3ba2199b5eb0ccd07069bb2a3b

Contents?: true

Size: 1.21 KB

Versions: 27

Compression:

Stored size: 1.21 KB

Contents

# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  protect_from_forgery # :secret => '44f8cf8a0491c23ae99c031a900123cc'
  
  # See ActionController::Base for details 
  # Uncomment this to filter the contents of submitted sensitive data parameters
  # from your application log (in this case, all fields with names like "password"). 
  # filter_parameter_logging :password
	
	before_filter :find_account
	around_filter :select_shard

	private
	def find_account
		aid = session[:account_id]
		if aid && aid.to_i != 0
		  begin
		    @account = Account.find(Integer(aid))
	    rescue ActiveRecord::RecordNotFound => e
	      RAILS_DEFAULT_LOGGER.warn "No such account #{aid}, skipping..."
	    end
	  end
	  session[:account_id] = nil unless @account
	end

	def select_shard(&block)
	  if @account
		  DataFabric.activate_shard(:shard => @account.shard, &block) 
	  else
	    yield
    end
	end
end

Version data entries

27 entries across 16 versions & 2 rubygems

Version Path
lookout-data_fabric-1.5.0 example30/app/controllers/application_controller.rb
data_fabric-1.3.3 example23/app/controllers/application_controller.rb
data_fabric-1.3.3 example30/app/controllers/application_controller.rb
data_fabric-1.3.2 example23/app/controllers/application_controller.rb
data_fabric-1.3.2 example30/app/controllers/application_controller.rb
data_fabric-1.3.1 example23/app/controllers/application_controller.rb
data_fabric-1.3.1 example30/app/controllers/application_controller.rb
data_fabric-1.3.0 example23/app/controllers/application_controller.rb
data_fabric-1.3.0 example30/app/controllers/application_controller.rb
data_fabric-1.2.7 example/app/controllers/application.rb
data_fabric-1.2.7 example23/app/controllers/application_controller.rb
data_fabric-1.2.1 example22/app/controllers/application.rb
data_fabric-1.0.0 example/app/controllers/application.rb
data_fabric-1.0.1 example/app/controllers/application.rb
data_fabric-1.0.2 example/app/controllers/application.rb
data_fabric-1.1.0 example/app/controllers/application.rb
data_fabric-1.2.0 example/app/controllers/application.rb
data_fabric-1.2.0 example22/app/controllers/application.rb
data_fabric-1.2.1 example/app/controllers/application.rb
data_fabric-1.2.2 example/app/controllers/application.rb