Skip to content

Commit

Permalink
Set size of the field to 60 (was 20) since Devise generated tokens ar…
Browse files Browse the repository at this point in the history
…e longer than before (if we cut generated token to 20, it could occur token conflicts since Devise ensure there is no conflict comparing the 60-chars generated tokens)
  • Loading branch information
Rémy Coutable committed Oct 5, 2010
1 parent d479a8c commit bd87511
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
27 changes: 25 additions & 2 deletions lib/devise_invitable/schema.rb
@@ -1,8 +1,31 @@
module DeviseInvitable
module Schema
# Creates invitation_token and invitation_sent_at.
# Add invitation_token and invitation_sent_at columns in the resource's database table.
#
# Examples
#
# # For a new resource migration:
# create_table :the_resources do
# t.database_authenticatable :null => false # you need at least this
# t.invitable
# ...
# end
# add_index :the_resources, :invitation_token # for invitable
#
# # or if the resource's table already exists, define a migration and put this in:
# change_table :the_resources do |t|
# t.string :invitation_token, :limit => 60
# t.datetime :invitation_sent_at
# t.datetime :invitation_accepted_at
# t.index :invitation_token # for invitable
# end
#
# # And allow encrypted_password to be null:
# change_column :the_resources, :encrypted_password, :string, :null => true
# # the following line is only if you use Devise's encryptable module!
# change_column :the_resources, :password_salt, :string, :null => true
def invitable
apply_devise_schema :invitation_token, String, :limit => 20
apply_devise_schema :invitation_token, String, :limit => 60
apply_devise_schema :invitation_sent_at, DateTime
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/active_record/templates/migration.rb
@@ -1,7 +1,7 @@
class DeviseInvitableAddTo<%= table_name.camelize %> < ActiveRecord::Migration
def self.up
change_table :<%= table_name %> do |t|
t.string :invitation_token, :limit => 20
t.string :invitation_token, :limit => 60
t.datetime :invitation_sent_at
t.index :invitation_token # for invitable
end
Expand Down

0 comments on commit bd87511

Please sign in to comment.