Questions tagged [validates-uniqueness-of]

validates_uniqueness_of is a rails helper method for determining whether an attribute is unique throughout a system

In Ruby on Rails, the validates_uniqueness_of method determines whether an attribute is unique across a system.

http://apidock.com/rails/v4.2.1/ActiveRecord/Validations/ClassMethods/validates_uniqueness_of

94 questions
0
votes
1 answer

Uniqueness of a pair of attributes not working

I have a User model that has among other things an email and a university_id I have added the following line to my model file: validates_uniqueness_of :email, :scope => [:university_id] but when I try to create a user with a same email but a…
marimaf
  • 5,382
  • 3
  • 50
  • 68
0
votes
1 answer

Bidirectional graph in rails

I have a simple model "Match" that is supposed to save the bi-directional link between two objects (of the same kind). class Match < ActiveRecord::Base belongs_to :obj1, :class_name => "MyModel", :foreign_key => :obj1_id belongs_to :obj2,…
0
votes
1 answer

Rails 3 validates_uniquess_of virtual field with scope

I am working on a Rails 3 app that is needing to run a validation on a virtual field to see if the record already exists... here is my model code: #mass-assignment attr_accessible :first_name, :last_name, :dob, :gender …
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
0
votes
1 answer

Best way to validate uniqueness of two fields together using scope in rails

In rails 3.2.3, I want to validate that a link model has a unique combination of two fields. I have a test and a validation that passes the test as shown below, but it seems there may be a better way to do this. For instance, would it be better to…
Anand
  • 3,690
  • 4
  • 33
  • 64
1 2 3 4 5 6
7