Skip to content
Browse files

Added confirmation code

  • Loading branch information...
1 parent 9b1f5a3 commit 1ac51ae74d2f87f7d4a176e794f47ec8b29cc5a3 @cbetta committed Aug 6, 2011
Showing with 15 additions and 6 deletions.
  1. +0 −1 Gemfile
  2. +1 −2 Gemfile.lock
  3. +1 −1 Rakefile
  4. +6 −1 app/models/authorisation.rb
  5. +5 −0 db/migrate/20110806145619_add_confirmation_code_to_authorisations.rb
  6. +2 −1 db/schema.rb
View
1 Gemfile
@@ -4,7 +4,6 @@ gem 'rails', '3.1.0.rc5'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
-gem "rake", "0.8.7"
gem 'sqlite3'
gem 'esendex'
View
3 Gemfile.lock
@@ -93,7 +93,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
- rake (0.8.7)
+ rake (0.9.2)
rdoc (3.9.1)
sass (3.1.7)
sass-rails (3.1.0.rc.5)
@@ -128,7 +128,6 @@ DEPENDENCIES
jquery-rails
pg
rails (= 3.1.0.rc5)
- rake (= 0.8.7)
sass-rails (~> 3.1.0.rc)
sqlite3
therubyracer-heroku (= 0.8.1.pre3)
View
2 Rakefile
@@ -1,7 +1,7 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
-
require File.expand_path('../config/application', __FILE__)
+require 'rake/dsl_definition'
Helpmenow::Application.load_tasks
View
7 app/models/authorisation.rb
@@ -5,14 +5,19 @@ class Authorisation < ActiveRecord::Base
:message => "must be a valid UK telephone number.",
:with => /^07[0-9]{9}$/
+ validates_uniqueness_of :phone_number
before_validation :convert_number
+ before_create :generate_confirmation_code
def convert_number
self.phone_number = self.phone_number.gsub(/[^0-9]/, "")
end
def code
- ""
+ return nil
+ end
+
+ def generate_confirmation_code
end
end
View
5 db/migrate/20110806145619_add_confirmation_code_to_authorisations.rb
@@ -0,0 +1,5 @@
+class AddConfirmationCodeToAuthorisations < ActiveRecord::Migration
+ def change
+ add_column :authorisations, :confirmation_code, :string
+ end
+end
View
3 db/schema.rb
@@ -10,13 +10,14 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110806124101) do
+ActiveRecord::Schema.define(:version => 20110806145619) do
create_table "authorisations", :force => true do |t|
t.string "phone_number"
t.boolean "confirmed"
t.datetime "created_at"
t.datetime "updated_at"
+ t.string "confirmation_code"
end
end

0 comments on commit 1ac51ae

Please sign in to comment.
Something went wrong with that request. Please try again.