Sha256: 23df6ea9deafda99e4339f7b5bd52da92e4a4e873cd2addefd5bdd22c4218faf
Contents?: true
Size: 1.18 KB
Versions: 24
Compression:
Stored size: 1.18 KB
Contents
class SubscribersController < ApplicationController def index @subscriber = Subscriber.new end def create @subscriber = Subscriber.new(params[:subscriber]) respond_to do |format| if @subscriber.save format.html { flash[:notice] = 'You have been subscribed successfully.' redirect_to :action => "index" } format.xml { render :xml => @subscriber, :status => :created } else format.html { render :action => "index" } format.xml { render :xml => @subscriber.errors, :status => :unprocessable_entity } end end end def destroy @subscriber = Subscriber.find_by_email(params[:email]) if @subscriber @subscriber.destroy respond_to do |format| format.html { flash[:notice] = "You have been unsubscribed." redirect_to :action => "index" } format.xml { head :ok } end else respond_to do |format| format.html { flash[:warning] = "Your email was not found. Are you sure you are subscribed?" redirect_to :action => "index" } format.xml { head :bad_request } end end end end
Version data entries
24 entries across 24 versions & 1 rubygems