I have Proposals and Members and Members can vote for a proposal only once. So, I have "Vote belongs_to :member, :proposal", but to make sure a member only votes once, I want to make sure that there isn''t a vote in the db with that member_id and proposal_id. I can just put the appropriate find in a vote.valid? but I wanted to make sure I wasn''t missing a nice rails shortcut. In other words, can I do something with "validates_uniqueness_of" to make it consider a pair of columns, member_id and proposal_id? thanks, b
You can by using trunk version of rails. Otherwise write your own validate method. -- Kent --- http://www.datanoise.com On 2/17/06, Ben Munat <bent@munat.com> wrote:> I have Proposals and Members and Members can vote for a proposal only once. > > So, I have "Vote belongs_to :member, :proposal", but to make sure a member only votes > once, I want to make sure that there isn''t a vote in the db with that member_id and > proposal_id. I can just put the appropriate find in a vote.valid? but I wanted to make > sure I wasn''t missing a nice rails shortcut. > > In other words, can I do something with "validates_uniqueness_of" to make it consider a > pair of columns, member_id and proposal_id? > > thanks, > > b > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
thanks... Kent Sibilev wrote:> You can by using trunk version of rails. Otherwise write your own > validate method. > > > -- > Kent > --- > http://www.datanoise.com > > > On 2/17/06, Ben Munat <bent@munat.com> wrote: > >>I have Proposals and Members and Members can vote for a proposal only once. >> >>So, I have "Vote belongs_to :member, :proposal", but to make sure a member only votes >>once, I want to make sure that there isn''t a vote in the db with that member_id and >>proposal_id. I can just put the appropriate find in a vote.valid? but I wanted to make >>sure I wasn''t missing a nice rails shortcut. >> >>In other words, can I do something with "validates_uniqueness_of" to make it consider a >>pair of columns, member_id and proposal_id? >> >>thanks, >> >>b >>_______________________________________________ >>Rails mailing list >>Rails@lists.rubyonrails.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails