-1

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 working?

atw
  • 5,428
  • 10
  • 39
  • 63
lamrin
  • 1,431
  • 4
  • 22
  • 34
  • What is the error you getting? The declaration seems to be fine. How do you try to create your relations? – dombesz Mar 22 '11 at 09:28
  • 1
    I don't see a HABTM relationship here? Could you please clarify the issue and what error you are seeing. – lebreeze Mar 22 '11 at 09:29
  • ooh yes, you're right lebreeze, it's not habtm, didn't notice that mentioned. – Spyros Mar 22 '11 at 09:31

1 Answers1

0

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.

Spyros
  • 46,820
  • 25
  • 86
  • 129