Module: RailsSecureToken
- Defined in:
- lib/rails_secure_token.rb,
lib/rails_secure_token/version.rb
Constant Summary collapse
- VERSION =
'0.0.3'
Class Method Summary collapse
Class Method Details
.find_or_create(root_path = Pathname.new('./')) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rails_secure_token.rb', line 6 def self.find_or_create(root_path=Pathname.new('./')) token_file = root_path.join '.secret' if File.exist? token_file # Use the existing token File.read(token_file).chomp else # Generate a new token of 64 random hexadecimal characters and store it in token_file token = SecureRandom.hex 64 File.write token_file, token token end end |