ryanb/uniquify — Issue #8: How to access object attribute in uniquify block
Author: regdog
Created: 2012-01-11 05:52:44+00:00
State: open

I had a User model and Email attribute. So I tried to generate unique token like below.

class User < ActiveRecord::Base
uniquify :token do
email.split('@').first.downcase << rand(9999999).to_s
end
end

But it finally raises error "undefined local variable or method `email'". How to pass the instance user object's email value to uniquify block?

Thanks Guru!