Class: Sooner::SubscribersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Sooner::SubscribersController
- Defined in:
- app/controllers/sooner/subscribers_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /subscribers POST /subscribers.json.
-
#new ⇒ Object
GET /subscribers/new GET /subscribers/new.json.
Instance Method Details
#create ⇒ Object
POST /subscribers POST /subscribers.json
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/sooner/subscribers_controller.rb', line 17 def create @subscriber = Subscriber.new(params[:subscriber]) if @subscriber.valid? if Sooner.csv_store @subscriber.save_csv end if Sooner.mongo_store @subscriber.save end SubscribersMailer.subscribed(@subscriber).deliver respond_with @subscriber, :location => root_url elsif @subscriber.errors[:email].include?("is already taken") || @subscriber.errors[:name].include?("is already taken") respond_with @subscriber, :location => root_url else flash[:notice] = Sooner.error_subscribed redirect_to root_url end end |
#new ⇒ Object
GET /subscribers/new GET /subscribers/new.json
6 7 8 9 10 11 12 13 |
# File 'app/controllers/sooner/subscribers_controller.rb', line 6 def new @subscriber = Subscriber.new respond_to do |format| format.html # new.html.erb format.json { render json: @subscriber } end end |