Class: SubscribersController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @subscriber = Subscriber.new(params[:subscriber])

  respond_to do |format|
    if @subscriber.save
      format.html do
        flash[:notice] = 'Thank you for subscribing.'
        redirect_to root_path
      end
      format.js
      format.json { render :json => @subscriber }
    else
      format.html
      format.js
      format.json { render :json => @subscriber.errors.full_messages, :status => :unprocessable_entity }
    end
  end
end