Class: Admin::SmsOnRails::DraftsController

Inherits:
BaseController
  • Object
show all
Includes:
SmsOnRails::CreationSupport
Defined in:
app/controllers/admin/sms_on_rails/drafts_controller.rb

Instance Method Summary collapse

Methods included from SmsOnRails::CreationSupport

#create_sms_draft, #send_sms, #show

Instance Method Details

#createObject



32
33
34
# File 'app/controllers/admin/sms_on_rails/drafts_controller.rb', line 32

def create
  create_sms_draft
end

#destroyObject

DELETE /admin/sms/drafts/1 DELETE /admin/sms/drafts/1.xml



55
56
57
58
59
60
61
62
63
# File 'app/controllers/admin/sms_on_rails/drafts_controller.rb', line 55

def destroy
  @draft = SmsOnRails::Draft.find(params[:id])
  @draft.destroy

  respond_to do |format|
    format.html { redirect_to(sms_drafts_url) }
    format.xml  { head :ok }
  end
end

#editObject

GET /admin/sms/drafts/1/edit



28
29
30
# File 'app/controllers/admin/sms_on_rails/drafts_controller.rb', line 28

def edit
  @draft = SmsOnRails::Draft.find(params[:id])
end

#indexObject

GET /admin/sms/drafts GET /admin/sms/drafts.xml



6
7
8
9
10
11
12
13
# File 'app/controllers/admin/sms_on_rails/drafts_controller.rb', line 6

def index
  @drafts = SmsOnRails::Draft.all

  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render :xml => @drafts }
  end
end

#newObject

GET /admin/sms/drafts/new GET /admin/sms/drafts/new.xml



18
19
20
21
22
23
24
25
# File 'app/controllers/admin/sms_on_rails/drafts_controller.rb', line 18

def new
  @draft = SmsOnRails::Draft.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @draft }
  end
end

#updateObject

PUT /admin/sms/drafts/1 PUT /admin/sms/drafts/1.xml



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/admin/sms_on_rails/drafts_controller.rb', line 38

def update
  @draft = SmsOnRails::Draft.find(params[:id])

  respond_to do |format|
    if @draft.update_attributes(params[:draft])
      flash[:notice] = 'Draft was successfully updated.'
      format.html { redirect_to(sms_draft_url(:id => @draft)) }
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @draft.errors, :status => :unprocessable_entity }
    end
  end
end