Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

How to access object attribute in uniquify block #8

regdog opened this Issue Jan 11, 2012 · 0 comments


None yet
1 participant

regdog commented Jan 11, 2012

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

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment