Class: Admin::SmsOnRails::PhoneNumbersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/sms_on_rails/phone_numbers_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /admin/sms_on_rails_phone_numbers POST /admin/sms_on_rails_phone_numbers.xml



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/controllers/admin/sms_on_rails/phone_numbers_controller.rb', line 58

def create
  @phone_number = SmsOnRails::PhoneNumber.new(params[:phone_number])

  respond_to do |format|
    if @phone_number.save
      flash[:notice] = 'PhoneNumber was successfully created.'
      format.html { redirect_to(sms_phone_number_path(:id => @phone_number)) }
      format.xml  { render :xml => @phone_number, :status => :created, :location => @phone_number }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @phone_number.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /admin/sms_on_rails_phone_numbers/1 DELETE /admin/sms_on_rails_phone_numbers/1.xml



92
93
94
95
96
97
98
99
100
# File 'app/controllers/admin/sms_on_rails/phone_numbers_controller.rb', line 92

def destroy
  @phone_number = SmsOnRails::PhoneNumber.find(params[:id])
  @phone_number.destroy

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

#editObject

GET /admin/sms_on_rails_phone_numbers/1/edit



52
53
54
# File 'app/controllers/admin/sms_on_rails/phone_numbers_controller.rb', line 52

def edit
  @phone_number = SmsOnRails::PhoneNumber.find(params[:id])
end

#indexObject

GET /admin/sms_on_rails_phone_numbers GET /admin/sms_on_rails_phone_numbers.xml



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/admin/sms_on_rails/phone_numbers_controller.rb', line 7

def index

  if params[:sms_outbound_id]
    @outbounds = SmsOnRails::Outbound.find( params[:sms_outbound_id] )
    @phone_numbers = [@outbounds.phone_number]
  end

 
  @phone_numbers ||= SmsOnRails::PhoneNumber.all

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

#newObject

GET /admin/sms_on_rails_phone_numbers/new GET /admin/sms_on_rails_phone_numbers/new.xml



42
43
44
45
46
47
48
49
# File 'app/controllers/admin/sms_on_rails/phone_numbers_controller.rb', line 42

def new
  @phone_number = SmsOnRails::PhoneNumber.new

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

#showObject

GET /admin/sms_on_rails_phone_numbers/1 GET /admin/sms_on_rails_phone_numbers/1.xml



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/admin/sms_on_rails/phone_numbers_controller.rb', line 25

def show

  if params[:sms_outbound_id]
    @outbounds = SmsOnRails::Outbound.find( params[:sms_outbound_id] )
    @phone_number = @outbounds.phone_number
  end

  @phone_number ||= SmsOnRails::PhoneNumber.find(params[:id])

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

#updateObject

PUT /admin/sms_on_rails_phone_numbers/1 PUT /admin/sms_on_rails_phone_numbers/1.xml



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'app/controllers/admin/sms_on_rails/phone_numbers_controller.rb', line 75

def update
  @phone_number = SmsOnRails::PhoneNumber.find(params[:id])

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