Sha256: 0cd1e403115a47463640a1a9596b653170b7170add62cb98f8d6c91586ac1fea

Contents?: true

Size: 887 Bytes

Versions: 1

Compression:

Stored size: 887 Bytes

Contents

module Spree
  module Admin
    class NewslettersController < Spree::Admin::BaseController
      def update
        SolidusNewsletter::Config[:title] = newsletter_params[:title]
        SolidusNewsletter::Config[:text] = newsletter_params[:text]

        if (title == newsletter_params[:title] && text == newsletter_params[:text]) &&
            (newsletter_params[:title].present? && newsletter_params[:text])
          flash[:success] = Spree.t(:'newsletter.admin.success')
        else
          flash[:error] = Spree.t(:'newsletter.admin.error')
        end

        redirect_to admin_newsletters_edit_path
      end

      private

      def title
        SolidusNewsletter::Config[:title]
      end

      def text
        SolidusNewsletter::Config[:text]
      end

      def newsletter_params
        params.require(:newsletters).permit(:title, :text)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_newsletter-1.0 app/controllers/spree/admin/newsletters_controller.rb