Hi,

The reason you're getting this error is because the "validates" 
functions are class level methods, whereas your check_duplicate function 
is an instance method. So, to fix this, just reference the "validates_" 
methods with the appropriate model name:

def check_duplicate
  User.validates_uniqueness_of :login,:scope =>[:email], :case_sensitive
end


Craig Demyanovich wrote:
> On Jan 29, 2008 1:54 AM, Yukti Vig <[EMAIL PROTECTED]> 
> wrote:
> 
>> undefined method `validates_uniqueness_of' for #<User:0x3752c24>
>>
>> Is there any issue with the "check_duplicate" not getting values of
>> login and email.
> 
> 
> I don't know if you can use the validates_* methods in callbacks, so I 
> don't
> know whether it makes sense for you to have received that error.
> 
> My first instinct would be to try something like
> 
> validates_uniqueness_of :login, :on => :create, ...
> 
> The TextMate snippet for validates_uniqueness_of adds an :on option, but 
> the
> Rails API docs don't list one. I don't have time to actually try it all 
> out
> here, but maybe you can use the :on option to indicate that the check 
> should
> be made only on :create.
> 
> Regards,
> Craig

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to