Module: ActiveAdminSimpleLife::SimpleMenu
- Includes:
- Extensions
- Included in:
- ActiveAdminSimpleLife
- Defined in:
- lib/active_admin_simple_life/simple_menu.rb
Instance Method Summary collapse
-
#for(klass, options = {}, &blk) ⇒ Object
def simple_menu_for(klass, options = {}).
Instance Method Details
#for(klass, options = {}, &blk) ⇒ Object
def simple_menu_for(klass, options = {})
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/active_admin_simple_life/simple_menu.rb', line 14 def for(klass, = {}, &blk) ActiveAdmin.register klass do = {index: {}, form: {}, filter: {}}.merge permitted_params = .delete :permitted_params permit_params(*(klass.main_fields + (permitted_params || []))) # menu_options = options.slice(:priority, :parent, :if) if .any? actions :all, except: [:show] controller.class_variable_set(:@@permitted_params, permitted_params) controller.class_variable_set(:@@klass, klass) controller do def scoped_collection permitted_params = self.class.class_variable_get :@@permitted_params self.class.class_variable_get(:@@klass).includes(*permitted_params.map{|symbol| ExtensionedSymbol.new(symbol).cut_id}) end end if permitted_params %i[index filter form].each do |action| send "#{action}_for_main_fields", klass, [action] unless [action][:skip] == true end instance_exec &blk if block_given? end end |