Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

How to access object attribute in uniquify block #8

Open
regdog opened this issue Jan 11, 2012 · 0 comments
Open

How to access object attribute in uniquify block #8

regdog opened this issue Jan 11, 2012 · 0 comments

Comments

@regdog
Copy link

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
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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant