Class: Virgo::SubscribersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/virgo/subscribers_controller.rb

Instance Method Summary collapse

Methods included from RenderHelper

#render_content, #with_format

Methods included from ApplicationHelper

#action?, #admin?, #admin_access?, #admin_view?, #alerts, #base_errors, #category_timestamp, #column_timestamp, #compact_html, #controller?, #decode_html_entities, #expanded_post_url, #is_admin_view?, #page_url, #post_time_format, #post_timestamp, #production?, #redis_timestamp_key_for, #site, #site_key, #superuser?, #tabbed_param, #word_count

Instance Method Details

#createObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/virgo/subscribers_controller.rb', line 5

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

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/virgo/subscribers_controller.rb', line 24

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