Sha256: 3eca0282791868f92a22ca4920a230a3957a2d7ea067ac9940a7702a5f9ab15f

Contents?: true

Size: 1.32 KB

Versions: 42

Compression:

Stored size: 1.32 KB

Contents

module Virgo
  class SubscribersController < ApplicationController
    skip_before_action :verify_authenticity_token

    def create
      @subscriber = Subscriber.new(subscriber_params)

      if @subscriber.save
        render json: {
          status: :success,
          subscriber: @subscriber,
          html: render_content(partial: '/virgo/subscribers/success_modal')
        }
      else
        render json: {
          status: :err,
          subscriber: @subscriber,
          message: @subscriber.errors.full_messages,
          html: render_content(partial: '/virgo/common/list_signup')
        }
      end
    end

    def modal
      if request.post?
        @subscriber = Subscriber.new(subscriber_params)

        if @subscriber.save
          render json: {
            status: :success,
            html: render_content(partial: '/virgo/subscribers/success_modal')
          }
        else
          render json: {
            status: :err,
            html: render_content('/virgo/subscribers/modal', layout: false)
          }
        end
      else
        @subscriber = Subscriber.new

        render json: {
          html: render_content('/virgo/subscribers/modal', layout: false)
        }
      end
    end

    private

    def subscriber_params
      params.permit(subscriber: [:email])[:subscriber]
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
virgo-0.3.17 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.16 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.15 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.14 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.13 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.12 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.11 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.10 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.9 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.8 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.7 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.6 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.4 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.3 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.2 app/controllers/virgo/subscribers_controller.rb
virgo-0.3.1 app/controllers/virgo/subscribers_controller.rb
virgo-0.3 app/controllers/virgo/subscribers_controller.rb
virgo-0.2.9 app/controllers/virgo/subscribers_controller.rb
virgo-0.2.8 app/controllers/virgo/subscribers_controller.rb
virgo-0.2.7 app/controllers/virgo/subscribers_controller.rb