Skip to content

Instantly share code, notes, and snippets.

View gertig's full-sized avatar

Andrew Gertig gertig

View GitHub Profile
@gertig
gertig / callme_controller.rb
Created November 8, 2010 14:39
controller/callme_controller.rb
# your Twilio authentication credentials
ACCOUNT_SID = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
ACCOUNT_TOKEN = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYY'
# version of the Twilio REST API to use
API_VERSION = '2010-04-01'
# base URL of this application
BASE_URL = "localhost:3000" #production ex: "http://appname.heroku.com/callme"
@gertig
gertig / directions.xml.builder
Created November 8, 2010 14:43
views/callme/directions.xml.builder
xml.instruct!
xml.Response do
xml.Say "Your appointment is located in a building near a road."
xml.Redirect @redirectto
end
@gertig
gertig / goodbye.xml.builder
Created November 8, 2010 14:44
views/callme/goodbye.xml.builder
xml.instruct!
xml.Response do
xml.Say "Good bye."
end
@gertig
gertig / hellomoto.xml.builder
Created November 8, 2010 14:46
views/callme/hellomoto.xml.builder
xml.instruct!
xml.Response do
xml.Gather(:action => @postto, :numDigits => 1) do
xml.Say "Hello. The Twilio API is pretty awesome."
xml.Say "Please press 1 to repeat this menu. Press 2 for directions. Or press 3 if you are done."
end
end
@gertig
gertig / index.html.erb
Created November 8, 2010 14:47
views/callme/index.html.erb
<h1>Twilio API demo</h1>
<h2 style="color: #ff0000"><%= params['msg'] %></h2>
<h3>Enter your phone number</h3>
<form action="/callme/makecall" method="post">
<input type="text" name="number" />
<input type="submit" value="Call me!">
</form>
@gertig
gertig / routes.rb
Created November 8, 2010 14:49
config/routes.rb
Callme::Application.routes.draw do
match ':controller(/:action(.:format))'
match ':controller(/:action(/:id(.:format)))'
end
avariable = PDFKit.new(File.read("#{Rails.root}/tmp/somepage.html"))
class NewMailer < ActionMailer::Base
default :from => "sendersemail@gmail.com"
require "net/http"
def registration_confirmation(person, thepage, email)
@person = person #Mailers are similar to Controllers as instance variables are passed to the View layer
@thepage = thepage
attachments["rails.png"] = File.read("#{Rails.root}/public/images/rails.png") #Used to test attachments, remove in production
attachments["#{thepage.id}.pdf"] = {:content => email }
class ThepagesController < ApplicationController
#Gertig Mailer Method
def mailit
#Used to send an email to user when they are created
#To make this action RESTful you should add the following to your routes.rb file (uncommented of course)
#resources :thepages do
# member do
<p id="notice"><%= notice %></p>
<p id="show_item"><%= link_to "Email This Page to User", mailit_thepage_path(@thepage) %></p>
<p id="show_item"><%= link_to "Download This Page as a PDF", thepage_path(@thepage, :format => "pdf")%></p>
<p id="show_item">
<b>Person's Name:</b>
<%= Person.find(@thepage.person_id).name %>
</p>