Validation for HABTM is not working, I used the following code:
Class GroupsUsers < ActiveRecord::Base
belongs_to :user
belongs_to :group
validates_uniqueness_of :user_id, :scope => :group_id
end
Does anyone have a solution as to why this is not w开发者_如何学Corking?
I think that it's probably the plural model name. Try using GroupUser instead.
EDIT
As noted in a comment above(i didn't notice at first), you say that you do a HABTM. You actually don't do that. It's more like the intermediate model of a has_many through association.
精彩评论