Class: Cms::Admin::ImagesController
- Inherits:
-
BaseController
- Object
- BaseController
- Cms::Admin::ImagesController
- Defined in:
- app/controllers/cms/admin/images_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/cms/admin/images_controller.rb', line 23 def create @image = current_site.images.build(image_params) @translation_locale = requested_locale if @image.save redirect_to admin_images_path, notice: t("cms.notices.image_uploaded") else render :new, status: :unprocessable_content end end |
#destroy ⇒ Object
45 46 47 48 49 |
# File 'app/controllers/cms/admin/images_controller.rb', line 45 def destroy @image.file.purge_later @image.destroy redirect_to admin_images_path, notice: t("cms.notices.image_deleted") end |
#edit ⇒ Object
18 19 20 21 |
# File 'app/controllers/cms/admin/images_controller.rb', line 18 def edit @translation_locale = requested_locale @image.image_translations.find_or_initialize_by(locale: @translation_locale) end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/cms/admin/images_controller.rb', line 8 def index @images = current_site.images.includes(:localised).ordered end |
#new ⇒ Object
12 13 14 15 16 |
# File 'app/controllers/cms/admin/images_controller.rb', line 12 def new @image = current_site.images.build @translation_locale = requested_locale @image.image_translations.build(locale: @translation_locale) end |
#update ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/cms/admin/images_controller.rb', line 34 def update @translation_locale = requested_locale @image.assign_attributes(image_params) if @image.save redirect_to admin_images_path, notice: t("cms.notices.image_updated") else render :edit, status: :unprocessable_content end end |