Creating unique association with Rails
How to create an unique association (many to many) with Rails ?
Ive : article +----开发者_Go百科-+ article_user +------+ user
I want that the user can mark only one time an article, not twice or more.
How can I do that ? I Tried with uniqueness it doesn't work.
Sounds like you're looking for a composite primary key - so that a combination of article and user is always unique in your joining table.
Last time I check this isn't natively possible in ActiveRecord - you might want to try something like this:
http://compositekeys.rubyforge.org/
Stu
精彩评论