(How?) Is it possible to use validates_uniqueness_of with a scope that is a belongs_to association? This is what I would like to do: class Lot < ActiveRecord::Base belongs_to :part, :include => true validates_uniqueness_of :identifier, :scope => :part end ...but (not surprisingly) when I run my unit test, I get: ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: lots.part Basically, I want to ensure that identifiers are unique for a given part. I think I''m going to have to write my own validation here, but I thought I would ask the question first. --wpd --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 15, 9:44 pm, Patrick Doyle <wpds...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ...but (not surprisingly) when I run my unit test, I get: > > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: > lots.part > > Basically, I want to ensure that identifiers are unique for a given part. > > I think I''m going to have to write my own validation here, but I thought I > would ask the question first.Well validates uniqueness of wants scope to be column, so give it one (part_id) ! Fred> > --wpd
On Tue, Sep 15, 2009 at 5:57 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > Basically, I want to ensure that identifiers are unique for a given part. > > Well validates uniqueness of wants scope to be column, so give it one > (part_id) ! > > Fred >Oh... duh! (sheepishly creeps back into his cave with very little light) Thanks Fred. And thanks for answering such blatantly simple questions. --wpd --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---