Displaying 4 results from an estimated 4 matches for "securerandom".
2010 Jan 18
3
The role of self and :: within a method of a model
...ed in the method here.
These two things are preventing me from comprehending the below code:
def hash_new_password
# First reset the salt to a new random string. You could choose a
# longer string here but for a salt, 8 bytes of randomness is probably
# fine. Note this uses SecureRandom which will use your platform''s
secure
# random number generator.
self.salt = ActiveSupport::SecureRandom.base64(8)
# Now calculate the hash of the password, with the salt prepended,
store
# store that in the database
self.hashed_password = Digest::SHA2.hexdige...
2012 May 12
12
before_save messing up
...Model
class User < ActiveRecord::Base
attr_accessible :email, :name, :password, :password_confirmation
has_secure_password
before_save :create_remember_token
.
.
.
.
.
.
.
private
def create_remember_token
self.remember_token = SecureRandom.urlsafe_base64
end
end
#sessions_controller.rb -------> Sessions Controller
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by_email(params[:session][:email])
if user && user.authenticate(params[:session][:password])...
2011 Apr 19
0
unicorn 3.6.0 release soon
Mainly small fixes, improvements, and workarounds for fork() issues
with pseudo-random number generators shipped with Ruby (Kernel#rand,
OpenSSL::Random (used by SecureRandom and also by Rails).
If there are any other fixes/improvements that could be useful let us
know. I think this is nearing the end of the line for the 3.x series
which will then go into maintenance mode. I''m looking at 4.x being the
crazy series that allows us to run thousands of worker _p...
2009 Nov 01
5
Headache with sessions being shared.
I have a really horrendous problem with sessions.
before_filter :find_cart_from_session
private
def find_cart_from_session
if session[:cart] # if there''s is a cart in the session
begin
@cart = Cart.find(session[:cart]) # return existing or new cart
rescue ActiveRecord::RecordNotFound
@cart = Cart.create
@cart.save
session[:cart] = @cart.id