I could easily skip that validation and always let a new vote through.
Only when the same user votes again their original vote would be
updated. That is totally a matter of taste. I just happen to like
being abel to change my mind and update my vote. That doen't work
better for rating users, posts or other "social stuff" that is does
for competition entries.

For that kind of saves I wish there was a Cake version of "INSERT ...
ON DUPLICATE KEY UPDATE...". For votes you would likely want to know
if the save was an update or not and inform the user, so it is no
great loss.

/Martin




On Sep 14, 2:51 pm, "rich...@home" <richardath...@gmail.com> wrote:
> I wrote one a while back and posted it to this group. can't seem to
> find it now, but here's a link to it stored elsewhere:
>
> http://markmail.org/message/nleqrkgtm2ji6sfe
>
> On Sep 14, 11:10 am, Shaun <sbef...@gmail.com> wrote:
>
>
>
> > I have a table called comment_ratings where users can rate comments up
> > or down.  It looks like this:
>
> > TABLE:  comment_ratings
> >     id => INT
> >     rating_value => TINYINT
> >     comment_id => INT
> >     user_id => INT
> >     created => DATETIME
> >     modified => DATETIME
>
> > Users should only be allowed one vote on each comment, so I have
> > created a unique key on two fields, comment_id and user_id. The name
> > of the key is unique_rating_per_user.  This works fine in my database,
> > but how can I add the unique validation to the CommentRating model?
> > As far as I know, isUnique only handles one field.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to