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 / new_sms_app
Created June 22, 2012 06:56
Adding SMS capabilities to your Rails Application
rails new sms_app --skip-sprockets --skip-javascript
@tjackiw
tjackiw / user_resource
Created June 22, 2012 06:57
Adding SMS capabilities to your Rails Application
rails g resource user name:string email:string phone:string verified:boolean --skip-assets
@tjackiw
tjackiw / user.rb
Created June 22, 2012 06:58
Adding SMS capabilities to your Rails Application
class User < ActiveRecord::Base
attr_accessible :email, :name, :phone
validates :name, presence: true
validates :email, :phone, presence: true, uniqueness: true
end
@tjackiw
tjackiw / gist:2970877
Created June 22, 2012 06:59
Adding SMS capabilities to your Rails Application
rails g controller verifications --skip-assets
@tjackiw
tjackiw / routes.rb
Created June 22, 2012 07:00
Adding SMS capabilities to your Rails Application
resources :users
resource :verifications
root to: 'users#new'
@tjackiw
tjackiw / users_controller.rb
Created June 22, 2012 07:01
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 / new.html.erb
Created June 22, 2012 07:01
Adding SMS capabilities to your Rails Application
<h1>User Registration</h1>
<%= form_for @user do |f| %>
<% if @user.errors.any? %>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
<% end %>
@tjackiw
tjackiw / verifications_controller.rb
Created June 22, 2012 07:03
Adding SMS capabilities to your Rails Application
class VerificationsController < ApplicationController
def create
end
end
@tjackiw
tjackiw / gist:2970896
Created June 22, 2012 07:03
Adding SMS capabilities to your Rails Application
gem 'twilio-ruby'
@tjackiw
tjackiw / twilio.yml
Created June 22, 2012 07:04
Adding SMS capabilities to your Rails Application
development:
from: 'your-from'
sid: 'your-sid'
token: 'your-token'