Module: Effective::CrudController::ClassMethods

Includes:
Dsl
Defined in:
app/controllers/concerns/effective/crud_controller.rb

Instance Method Summary collapse

Methods included from Dsl

#after_commit, #after_error, #after_save, #before_render, #before_save, #button, #on, #page_title, #resource_scope, #submit

Instance Method Details

#define_actions_from_routesObject

Automatically respond to any action defined via the routes file



26
27
28
29
30
31
32
33
34
# File 'app/controllers/concerns/effective/crud_controller.rb', line 26

def define_actions_from_routes
  (effective_resource.member_actions - effective_resource.crud_actions).each do |action|
    define_method(action) { member_action(action) }
  end

  (effective_resource.collection_actions - effective_resource.crud_actions).each do |action|
    define_method(action) { collection_action(action) }
  end
end

#define_permitted_params_from_modelObject



36
37
38
39
40
41
42
43
44
# File 'app/controllers/concerns/effective/crud_controller.rb', line 36

def define_permitted_params_from_model
  if effective_resource.model.present?
    define_method(:effective_resource_permitted_params) { resource_permitted_params } # save.rb
  end

  if effective_resource.active_model?
    define_method(:effective_resource_permitted_params) { resource_active_model_permitted_params } # save.rb
  end
end

#effective_resourceObject



21
22
23
# File 'app/controllers/concerns/effective/crud_controller.rb', line 21

def effective_resource
  @_effective_resource ||= Effective::Resource.new(controller_path)
end