Skip to content

Instantly share code, notes, and snippets.

View tjackiw's full-sized avatar

Thiago Jackiw tjackiw

  • San Francisco Bay Area
View GitHub Profile
@tjackiw
tjackiw / twilio.rb
Created June 22, 2012 07:04
Adding SMS capabilities to your Rails Application
path = File.join(Rails.root, "config/twilio.yml")
TWILIO_CONFIG = YAML.load(File.read(path))[Rails.env] || {'sid' => '', 'from' => '', 'token' => ''}
@tjackiw
tjackiw / users_controller.rb
Created June 22, 2012 07:05
Adding SMS capabilities to your Rails Application
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
render text: "Thank you! You will receive an SMS shortly with verification instructions."
@tjackiw
tjackiw / verifications_controller.rb
Created June 22, 2012 07:06
Adding SMS capabilities to your Rails Application
class VerificationsController < ApplicationController
before_filter :get_user
def create
@user.update_attribute(:verified, true)
# You could send another message acknowledging the verificaton
head :ok
end
@tjackiw
tjackiw / gist:2970913
Created June 22, 2012 07:07
Adding SMS capabilities to your Rails Application
{
"AccountSid"=>"<string>",
"Body"=>"the message content",
"ToZip"=>"<string>",
"FromState"=>"<string>",
"ToCity"=>"<string>",
"SmsSid"=>"<string>",
"ToState"=>"<string>",
"To"=>"<string>",
"ToCountry"=>"<string>",
@tjackiw
tjackiw / gist:2970916
Created June 22, 2012 07:08
Adding SMS capabilities to your Rails Application
# Manual install
gem install showoff-io
# Or via Bundle
gem 'showoff-io', group: :development
bundle install
# Sharing your localhost on port 3000
show 3000
@tjackiw
tjackiw / gist:2970918
Created June 22, 2012 07:08
Adding SMS capabilities to your Rails Application
# Manual install
gem install tunnlr_connector
# Or via Bundle
gem 'tunnlr_connector', group: :development
bundle install
# Configure for the first time
rake tunnlr:configure
@tjackiw
tjackiw / gist:2970921
Created June 22, 2012 07:10
Adding SMS capabilities to your Rails Application
group :test do
gem 'rr'
end
@tjackiw
tjackiw / test_helper.rb
Created June 22, 2012 07:11
Adding SMS capabilities to your Rails Application
class ActiveSupport::TestCase
include RR::Adapters::TestUnit
end
@tjackiw
tjackiw / users_controller_test.rb
Created June 22, 2012 07:11
Adding SMS capabilities to your Rails Application
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
test "#new" do
get :new
assert_response :success
assert_template :new
end
@tjackiw
tjackiw / mocked_client.rb
Created June 22, 2012 07:12
Adding SMS capabilities to your Rails Application
class MockedTwilioClient
def method_missing(*args)
self
end
end