Thank you for your reply.
I have tried two of what your suggested.
":message=>"user #{name} has already " shows "user has already"
the #{name} will just be skipped though I had set a value in the model
object.
":message=>"user [EMAIL PROTECTED] has already" shows error message "@name not
defined"
I will try this
:message=>"user #{attributes[:name]} has already
and I will tell you the result here.
Anyway, thank you.
On Oct 2, 3:42 pm, Pokkai Dokkai <[EMAIL PROTECTED]>
wrote:
> boblu wrote:
> > Class User < ActiveRecord::Base
> > validates_uniqueness_of :name,
> > :message=>"user #{self.name} has already
> > exist!"
> > end
>
> > It cannot pass, and the following error shows out:
> > undefined method 'name' in model
>
> :message=>"user #{name} has already
> or
> :message=>"user #{attributes[:name] || @name} has already
> or
> write your own validation method
> --
> Posted viahttp://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
-~----------~----~----~----~------~----~------~--~---