Sha256: 3a667eb5543f7a3f294d9c8527a1313cae630944f7f69a9a51ed9eb383df061a

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

module Gemgento
  class SubscribersController < ApplicationController

    respond_to :js, :json, :html

    def new
      @subscriber = Subscriber.new

      respond_with @subscriber
    end

    def create
      @subscriber = Subscriber.create(subscriber_params)

      respond_to do |format|
        if @subscriber.save
          format.html
          format.js { render action: 'create', layout: false }
          format.json { render json: { result: true, subscriber: @subscriber } }
        else
          format.html
          format.js { render action: 'errors', layout: false }
          format.json { render json: { result: false, errors: @subscriber.errors.full_messages } }
        end
      end
    end

    private

    def subscriber_params
      params.require(:subscriber).permit(:first_name, :last_name, :email, :country_id, :city)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemgento-2.8.0 app/controllers/gemgento/subscribers_controller.rb