Project

verifiable

0.0
No commit activity in last 3 years
No release in over 3 years
Allows associatons to be create that require verification, i.e. email addresses or phone numbers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

= 2.3.11
>= 1.0.0
= 0.8.7
= 1.3.3
 Project Readme

Verifiable¶ ↑

Description¶ ↑

Creates verified associations. Verified associations are similar to regular associations, except that a step has been taken to verify the integrity of the association.

Usage¶ ↑

Add verifiable to your Gemfile (or whatever if you’re not using bundler):

gem "verifiable"

Run the generator to create the necessary database migration and run it:

script/generate verifiable_migration
rake db:migrate

Include Verifiable::Associations in your classes and specify the correct type of association:

class User < ActiveRecord::Base

  include Verifiable::Associations
  has_many_verifiable :phone_numbers

end

class PhoneNumber < ActiveRecord::Base

  include Verifiable::Associations
  verifiable_for :users

end

Create some associations that need verification:

user = User.create
phone_number = user.phone_numbers.create

Associated objects don’t show up until they’re verified:

>> user.phone_numbers == []
=> true

Get unverified objects like this:

>> user.unverified_phone_numbers == [phone_number]
=> true

Get the verification code for an association (code is a random 4 digit string):

code = user.verification_code_for(phone_number)

Verify the association (returns true if code is correct):

user.verify!(phone_number, code)

Once verified, the associated objects show up:

>> user.phone_numbers == [phone_number]
=> true

To create a verification that has a different type of code:

user = User.create
phone_number = PhoneNumber.create
Verifiable::Verification.create(:code => "abcd", :object => user, :verifiable => phone_number)

LICENSE¶ ↑

The MIT License, see LICENSE

TODO¶ ↑

  • Make singular associations work (has_one)

  • Figure out a way to make association specific verification code generators