Class: CrudTestModelsController
- Inherits:
-
CrudController
- Object
- ApplicationController
- ListController
- CrudController
- CrudTestModelsController
- Defined in:
- lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb
Overview
Controller for the dummy model.
Constant Summary collapse
- HANDLE_PREFIX =
:nodoc:
'handle_'.freeze
Instance Attribute Summary collapse
-
#called_callbacks ⇒ Object
readonly
Returns the value of attribute called_callbacks.
-
#should_redirect ⇒ Object
Returns the value of attribute should_redirect.
Instance Method Summary collapse
Methods inherited from CrudController
before_render_form, #destroy, #edit, #new, #update
Methods included from DryCrud::GenericModel
#ivar_name, #model_ivar_get, #model_ivar_set, #model_scope, #path_args
Methods included from DryCrud::Nestable
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *_args) ⇒ Object (private)
handle the called callbacks
93 94 95 96 97 98 99 |
# File 'lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb', line 93 def method_missing(sym, *_args) if sym.to_s.starts_with?(HANDLE_PREFIX) called_callback(sym.to_s[HANDLE_PREFIX.size..].to_sym) else super end end |
Instance Attribute Details
#called_callbacks ⇒ Object (readonly)
Returns the value of attribute called_callbacks.
21 22 23 |
# File 'lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb', line 21 def called_callbacks @called_callbacks end |
#should_redirect ⇒ Object
Returns the value of attribute should_redirect.
22 23 24 |
# File 'lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb', line 22 def should_redirect @should_redirect end |
Instance Method Details
#create ⇒ Object
37 38 39 40 41 |
# File 'lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb', line 37 def create super do |_format, success| flash[:notice] = 'model got created' if success end end |
#index ⇒ Object
28 29 30 31 |
# File 'lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb', line 28 def index entries render plain: 'index js' if request.format.js? end |
#show ⇒ Object
33 34 35 |
# File 'lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb', line 33 def show render html: 'custom html' if entry.name == 'BBBBB' end |