Class: Robocall::RobocallsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/robocall/robocalls_controller.rb

Instance Method Summary collapse

Instance Method Details

#connected_to_callerObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/robocall/robocalls_controller.rb', line 13

def connected_to_caller
  @r = Robocall.find_by_id(params[:id])

  error = ''
  error = "Caller record #{params[:id]} not found" unless @r
  error = "No token provided" unless params[:token]
  error = "The token was invalid" unless @r && @r.token == params[:token]
  if error != ''
    @error = error
    template = <<'HAML'
<?xml version='1.0' encoding='UTF-8'?>
%Response
  %Say{:voice => 'alice'}
An error has occured retreieveing your automatic message.
Specifically,
= error
HAML
    xml = Haml::Engine.new(template).to_html(Object.new, {:error => error} )
    render :xml => xml, :content_type => 'application/xml'
  else
    render :xml => @r.xml, :content_type => 'application/xml'
  end
end

#set_formatObject



9
10
11
# File 'app/controllers/robocall/robocalls_controller.rb', line 9

def set_format
  request.format = 'xml'
end