Module: CrudEntities
- Extended by:
- ActiveSupport::Concern
- Includes:
- ProcessedForms
- Included in:
- Admin::BiovisionComponentsController, Admin::DynamicBlocksController, Admin::DynamicPagesController, Admin::NavigationGroupsController, Admin::TokensController, Admin::UsersController
- Defined in:
- app/controllers/concerns/crud_entities.rb
Overview
Adds method for CRUD
Instance Method Summary collapse
-
#check ⇒ Object
post [scope]//check.
-
#create ⇒ Object
post [scope]/.
-
#destroy ⇒ Object
delete [scope]//:id.
-
#edit ⇒ Object
get [scope]//:id/edit.
-
#index ⇒ Object
get [scope]/.
-
#new ⇒ Object
get [scope]//new.
-
#search ⇒ Object
get [scope]//search?q=.
-
#show ⇒ Object
get [scope]//:id.
-
#update ⇒ Object
patch [scope]//:id.
Instance Method Details
#check ⇒ Object
post [scope]//check
26 27 28 29 30 |
# File 'app/controllers/concerns/crud_entities.rb', line 26 def check @entity = model_class.instance_for_check(params[:entity_id], entity_parameters) render 'shared/forms/check' end |
#create ⇒ Object
post [scope]/
39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/concerns/crud_entities.rb', line 39 def create @entity = component_handler.new_entity(model_class, creation_parameters) if @entity.respond_to?(:meta=) if @entity.save form_processed_ok(path_after_save) else form_processed_with_error(view_for_new) end end |
#destroy ⇒ Object
delete [scope]//:id
66 67 68 69 |
# File 'app/controllers/concerns/crud_entities.rb', line 66 def destroy flash[:notice] = t('.success') if @entity.destroy redirect_to path_after_destroy end |
#edit ⇒ Object
get [scope]//:id/edit
50 51 52 |
# File 'app/controllers/concerns/crud_entities.rb', line 50 def edit render view_for_edit end |
#index ⇒ Object
get [scope]/
15 16 17 18 19 |
# File 'app/controllers/concerns/crud_entities.rb', line 15 def index @filter = params[:filter]&.permit!.to_h data_helper = Biovision::Helpers::DataHelper.new(model_class, @filter) @collection = data_helper.administrative_collection(current_page) end |
#new ⇒ Object
get [scope]//new
33 34 35 36 |
# File 'app/controllers/concerns/crud_entities.rb', line 33 def new @entity = model_class.new render view_for_new end |
#search ⇒ Object
get [scope]//search?q=
9 10 11 12 |
# File 'app/controllers/concerns/crud_entities.rb', line 9 def search q = param_from_request(:q) @collection = model_class.search(q).list_for_administration.page(current_page) end |
#show ⇒ Object
get [scope]//:id
22 23 |
# File 'app/controllers/concerns/crud_entities.rb', line 22 def show end |
#update ⇒ Object
patch [scope]//:id
55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/concerns/crud_entities.rb', line 55 def update if @entity.respond_to?(:meta=) if component_handler.update_entity(@entity, entity_parameters) form_processed_ok(path_after_save) else form_processed_with_error(view_for_edit) end end |