class User < ActiveRecord::Base
has_many :products, :dependent => :destroy
end
class Product < ActiveRecord::Base
belongs_to :user
validates :itemcode, :uniqueness => true
end
Now case,
System has number of users who can insert product information with
itemcode
uniqueness, but we need uniqueness validation with user_id and
itemcode.System need to check join table validation for new item with
user_id and itemcode.
It is no good just saying it is not working, what response do you
expect from that?
Gautam P. suggested that you read the documentation, but four minutes
later you posted your reply so I suspect you did not do that. Go back
and read the documentation, check your code, try things in the rails
console to try and work out what the problem is.
Then if you still cannot get it to work show us the code ( just the
relevant bits in the model where you specify the validation) and some
results from saving records in the Rails Console that shows that it
does not work.