Class: Spina::Admin::Journal::LicencesController
- Inherits:
-
ApplicationController
- Object
- AdminController
- ApplicationController
- Spina::Admin::Journal::LicencesController
- Defined in:
- app/controllers/spina/admin/journal/licences_controller.rb
Overview
Controller for Licence records.
Constant Summary collapse
- PARTS_PARAMS =
:name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id, { images_attributes: %i[filename signed_blob_id image_id alt], content_attributes: [ :name, :title, { parts_attributes: [ :name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id, { images_attributes: %i[filename signed_blob_id image_id alt] } ] } ] } ].freeze- CONTENT_PARAMS =
Spina.config.locales.inject({}) do |params, locale| params.merge("#{locale}_content_attributes": [*PARTS_PARAMS]) end
- PARAMS =
[:name, :abbreviated_name, { **CONTENT_PARAMS }].freeze
- PARTS =
%w[text url logo].freeze
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'app/controllers/spina/admin/journal/licences_controller.rb', line 42 def create @licence = Licence.new(licence_params) if @licence.save redirect_to admin_journal_licences_path, success: t('.saved') else render :new end end |
#destroy ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'app/controllers/spina/admin/journal/licences_controller.rb', line 59 def destroy @licence.destroy respond_to do |format| format.html do redirect_to admin_journal_licences_path, success: t('.deleted') end end end |
#edit ⇒ Object
40 |
# File 'app/controllers/spina/admin/journal/licences_controller.rb', line 40 def edit; end |
#index ⇒ Object
30 31 32 |
# File 'app/controllers/spina/admin/journal/licences_controller.rb', line 30 def index @licences = Licence.sorted end |
#new ⇒ Object
34 35 36 37 38 |
# File 'app/controllers/spina/admin/journal/licences_controller.rb', line 34 def new @licence = Licence.new build_parts t('.new') end |
#update ⇒ Object
51 52 53 54 55 56 57 |
# File 'app/controllers/spina/admin/journal/licences_controller.rb', line 51 def update if @licence.update(licence_params) redirect_to admin_journal_licences_path, success: t('.saved') else render :edit end end |