Sha256: 6f97b0cd81ca54e382d927db21a0e0662d510d24e33a7b8967b1a55c23c174ee
Contents?: true
Size: 1.34 KB
Versions: 19
Compression:
Stored size: 1.34 KB
Contents
module LoadBehind class ControllerResource < CanCan::ControllerResource def initialize(controller, name, parent = nil, options = {}) super(controller, name, parent, options) end def load_resource puts "AjaxLoading::load_resource" params = @controller.params set_controller_var 'container', params[:container] if params.has_key?(:container) if params.has_key?(:associated) ass_params = params[:associated] relation = ass_params["class_name"].constantize.find(ass_params["id"]) association = ass_params["association"] set_controller_var 'container', get_controller_var('container') || relation.element_id(:show, association) self.model_instance = relation.send(association) elsif collection_action? self.model_instance = model_class.where('1=1') else super end set_controller_var 'container', get_controller_var('container') || 'main_container' end def find(id) self.model_instance ||= base.lookup(id) end private def set_controller_var(name, value) name = '@'+name unless name.include?('@') @controller.instance_variable_set(name, value) end def get_controller_var(name) name = '@'+name unless name.include?('@') @controller.instance_variable_get(name) end end end
Version data entries
19 entries across 19 versions & 1 rubygems