radhames brito | 7 Sep 16:33
Picon
Gravatar

Re: Re: weird stuff: validate_uniqueness_of with :scope does not work

dont use the before_save use transactions that way it will roll back both actions if there is an error.
and dont use that function you have with the each and all use

find_or_create_by_name(name)it does what you want.


On Tue, Sep 7, 2010 at 7:20 AM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:


On Sep 7, 11:55 am, Swartz <netv... <at> gmail.com> wrote:

> However, as soon as I create a member through a controller-backed
> form, the uniqueness validation gets tripped up.  I get validation
> error from my validates_uniqueness_of as "Folder already exists for
> this member". Which shouldn't happen.
>
> For some strange reason :scope gets ignored and thus uniqueness check
> isn't properly scoped by member_id...
>
> The weird part is that it all works in script/console, but not via web
> forms.
>

Is there some odd interaction because you're creating these folders
from a before_save  (ie the member's id has not yet been set)?

Fred

> Any suggestions???
>
> Thanks in advance!

--
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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


--
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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Gmane