Class: Tramway::EntitiesController
- Inherits:
-
Object
- Object
- Tramway::EntitiesController
- Defined in:
- app/controllers/tramway/entities_controller.rb
Overview
Main controller for entities pages
Instance Method Summary collapse
-
#create ⇒ Object
rubocop:disable Metrics/AbcSize.
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
Instance Method Details
#create ⇒ Object
rubocop:disable Metrics/AbcSize
39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/tramway/entities_controller.rb', line 39 def create @record = tramway_form model_class.new, namespace: entity.namespace if @record.submit params[model_class.model_name.param_key] redirect_to public_send(entity.show_helper_method, @record.id), notice: t('tramway.notices.created') else render :new end end |
#index ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/tramway/entities_controller.rb', line 13 def index if index_scope.present? model_class.public_send(index_scope) else model_class.order(id: :desc) end.page(params[:page]) => entities @entities = entities @namespace = entity.namespace end |
#new ⇒ Object
34 35 36 |
# File 'app/controllers/tramway/entities_controller.rb', line 34 def new @record = tramway_form model_class.new, namespace: entity.namespace end |
#show ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/controllers/tramway/entities_controller.rb', line 25 def show @record = tramway_decorate( model_class.find(params[:id]), namespace: entity.namespace ).with(view_context:) set_associations end |