Module: CrudEntities
- Extended by:
- ActiveSupport::Concern
- Included in:
- 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
25 26 27 28 29 |
# File 'app/controllers/concerns/crud_entities.rb', line 25 def check @entity = model_class.instance_for_check(params[:entity_id], entity_parameters) render 'shared/forms/check' end |
#create ⇒ Object
post [scope]/
38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/concerns/crud_entities.rb', line 38 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
65 66 67 68 |
# File 'app/controllers/concerns/crud_entities.rb', line 65 def destroy flash[:notice] = t('.success') if @entity.destroy redirect_to path_after_destroy end |
#edit ⇒ Object
get [scope]//:id/edit
49 50 51 |
# File 'app/controllers/concerns/crud_entities.rb', line 49 def edit render view_for_edit end |
#index ⇒ Object
get [scope]/
14 15 16 17 18 |
# File 'app/controllers/concerns/crud_entities.rb', line 14 def index @filter = params[:filter]&.permit!.to_h data_helper = Biovision::Helpers::DataHelper.new(model_class) @collection = data_helper.administrative_collection(current_page, @filter) end |
#new ⇒ Object
get [scope]//new
32 33 34 35 |
# File 'app/controllers/concerns/crud_entities.rb', line 32 def new @entity = model_class.new render view_for_new end |
#search ⇒ Object
get [scope]//search?q=
8 9 10 11 |
# File 'app/controllers/concerns/crud_entities.rb', line 8 def search q = param_from_request(:q) @collection = model_class.search(q).list_for_administration.page(current_page) end |
#show ⇒ Object
get [scope]//:id
21 22 |
# File 'app/controllers/concerns/crud_entities.rb', line 21 def show end |
#update ⇒ Object
patch [scope]//:id
54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/concerns/crud_entities.rb', line 54 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 |