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

How to access object attribute in uniquify block #8

@regdog

Description

@regdog

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions