Reputation: 5885
I am having a problem with my validation for a model. I want to ensure that for a particular Website that each Inventory name will remain unique.
When I add this to my model:
validates :name, :uniqueness => { :scope => :website }
I get this error:
TypeError - Cannot visit Account::Website:
The relationship is setup like this:
class Inventory < ActiveRecord::Base
belongs_to :website, :class_name => 'Account::Website'
Upvotes: 1
Views: 63
Reputation: 5885
I have no idea but using this instead:
validates :name, :uniqueness => { :scope => :website_id }
Fixes it.
Anyone able to share why?
Upvotes: 1