search for: validates_uniqueness_of

Displaying 20 results from an estimated 250 matches for "validates_uniqueness_of".

2006 Mar 02
4
Getting Acts_as_Paranoid to work with validates_uniqueness_of
Hello I''ve been using Acts_as_Parnoid for a while and it has been working well but I am now having a slight issue with it. I have a company table were I would like to use validates_uniqueness_of :company_name. This validation works if a company exists in the database and has not been deleted. However, I also would like the validates_uniqueness_of to work if a company has previously been deleted and has been flagged in the deleted_at column. Currently, if a company has been dele...
2006 May 10
4
validates_uniqueness_of and create atomicity
Hi folks, I have a question regarding validates_uniqueness_of, and similar before-filter-like events attempting to guarantee some DB state prior to modification. >From my reading of ActiveRecord, validate_uniqueness_of appears to cause a SELECT on the underlying table attempting to ensure that a record with ID(s) specified in the validates_uniqueness_of s...
2006 Apr 27
4
customize validates_uniqueness_of
I need to modify the validates_uniqueness_of function so that it will check that the string is unique but only in its own category. For example right now I have validates_uniqueness_of :title so let''s say I have the :title "Title 1" already in the database with the :category of "1" then if i wanted to enter...
2006 May 18
1
validates_uniqueness_of
I used validates_uniqueness_of it is case insensitive, it takes only admin not Admin. So please help me out how to put validates_uniqueness_of as case sensitive Thanks in Advance Surekha.Matte -- Posted via http://www.ruby-forum.com/.
2008 Sep 19
0
validates_uniqueness_of: passing a method to :scope
I was wondering if anybody knows an easy way to pass a method name as the scope option to a validates_uniqueness_of validation on a AR model? For example, I have nested models a bit like: class Survey has_many :areas end class Area belongs_to :survey has_many :questions, :order => ''position'' validates_uniqueness_of :position, :scope => : survey_id end class Question belongs_...
2008 Aug 21
1
validates_uniqueness_of not working - urgent
I''m using restful_authentication to let users register and login. Lately, however, I''m seeing multiple login and emails being created even though I have validates_uniqueness_of as below: user.rb validates_uniqueness_of :login, :email, :case_sensitive => false mysql> select id, login, email, created_at, state from users; +----+---------------+---------------------------- +---------------------+---------+ | id | login | email | create...
2006 Sep 12
4
ActiveRecord Validations - validates_uniqueness_of
Hello, I''m wanting to use Mocha and Stubba for my tests in place of the default Rails testing with fixtures. I have the following class: class Person < ActiveRecord::Base validates_uniqueness_of :email end and am wondering how I can test to ensure that the validates_uniqueness_of validation is running. Any ideas? -Jonathan
2006 Dec 06
2
validates_uniqueness_of where scope euqals created_by "magic" field
I have the following ActiveRecord objects: class Recipe < ActiveRecord::Base has_many :ratings, :dependent => true . . . end class Rating < ActiveRecord::Base validates_uniqueness_of :created_by, :scope => :recipe_id belongs_to :recipe, :counter_cache => true . . . end The created_by field on Rating is implemented as a "magic" field similar to this: http://wiki.rubyonrails.org/rails/pages/Howto+Add+created_by+and+updated_by. It is working fine. The validat...
2010 Aug 28
1
validates_uniqueness_of missing in rails 3.0 rc2?
Has anybody noticed validates_uniqueness_of missing in rails 3.0 rc2? I''m not sure if this is a bug or I''m just doing something wrong. Here''s what I''m doing. Class 1: class Title < ActiveRecord::Base validates_length_of :language, :is => 3 validates_uniqueness_of :language, :scope => :b...
2006 Jan 20
3
Is there a way to validate a model w/o saving it?
I have some code in my controller which looks like this: if request.post? and @account.save and @user.save ... end and in my Account and User models I have many :validates, like so account.rb validates_presence_of :subdomain, :on => :create validates_uniqueness_of :subdomain, :on => :create, :message => "is already being used" validates_exclusion_of :subdomain, :in => %w{ www blog weblog forum info }, :message => "invalid subdomain" user.rb validates_presence_of :login validates_uniqueness_of :login, :on => :create...
2006 Aug 10
2
validates_uniqueness_of problem
...unique jackson m unique miller m isn''t unique So I want to check the name and sex be together unique. The name isn''t individually. Because when I use the following codelines, the third entry in the example isn''t unique, but I would! validates_uniqueness_of :name validates_uniqueness_of :sex thx for your help! -- Posted via http://www.ruby-forum.com/.
2006 Jun 07
3
validates_uniqueness_of two fields
Is it possible to do a validates_uniqueness_of :name, :zip but only in that context? I''d like to be able to have that zip used again, but not in conjunction with a name already with that zip. Does that make sense? -- Posted via http://www.ruby-forum.com/.
2006 May 10
1
Validates_uniqueness_of multiple field combo?
Hello, I am new to Ruby on rails and this is therefore probably trivial. Lets say I have 3 tables - users[id,name, age, ...], interests[id,name,description, ...], and finally a table user_interests[id,user_id,interest_id] to link a user to a set of interests. Now there is no problem to put validates_uniqueness_of :name in the user-model to ensure that I only have one Lenny, but how do I validate the uniqueness of Lenny''s interests in the user_interest-table? Ie, is there a method to validate that an entry into a table is unique in terms of several fields? Lenny -fishing, Lenny - programming OK,...
2006 Mar 26
9
validate_uniqueness_of {combination of fields} ???
I''ve looked at the validates documentation and it appears that validates_uniqueness_of works on only one field at a time. So I can, for example, validate that "sam" is unique to the record set, and that "smith" is unique to the record set. My problem is that each record includes two fields, the _combination_ of which must be unique to the record set, but each of...
2007 Jul 30
3
validates_uniqueness_of doesn't work if value tested is numeric and column is string
Hello all, I am working through the depot example in the rails book. If I add a validates_uniqueness_of to a string column in the model, and then try to create a record with a number in this string column I get an SQL error. Looks like the SQL generated to test for uniqueness does not quote the value if it''s numeric even though it''s comparing against a varchar column. It does some...
2006 Apr 05
2
validates_uniqueness_of with habtm
...ntry < ActiveRecord::Base has_and_belongs_to_many :categories end similarly: class Category < ActiveRecord::Base has_and_belongs_to_many :entries end I wish to make sure that the owner doesn''t add the same category to a given entry more than once... I''m thinking that validates_uniqueness_of should be usable here. But can''t figure out how to include it. ideas? thanks -- Posted via http://www.ruby-forum.com/.
2007 Nov 08
1
validates_uniqueness_of with conditions
Hello I have a user table in my db. A user has a status field, status is an INT an can be between 1-5. When a new user sign up I want to use "validates_uniqueness_of :login" in user model. But I don''t want to validate the new user against users with status == 5. Can I do this with some :if or :conditions? (I prefer not to use my own validate method) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~...
2007 Nov 18
1
validates_uniqueness_of question
Given three models: a design model, a votes model, and a users model the problem is a user can only vote for a design once. If I do a validates_uniqueness_of :user in the votes model that means a user can only vote once, period. What I want is to say a user can only vote for a single design once. Anyone know the best way to do this? Thanks. JB --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed...
2009 Jun 26
0
validates_uniqueness_of and MySQL enum type
I tried to check validates_uniqueness_of for a MySql enum type column with a scope given, like this: validates_uniqueness_of :phone_type, :scope => :user_id And It didn''t work. When I check the SQL statement for doing this validation, it is like this: SELECT `phone_numbers`.id FROM `phone_numbers` WHERE (`phone_numbers`.`ph...
2009 Oct 02
0
Problems with validates_uniqueness_of
...b i was following the video class from Lynda, and i introduce more code in my aplicacion, my application is a music store web site, ok so i add the funcionality of add clients, for that i need from my client, his user and password, so it will be 1 user per client, for that reason i use at my model validates_uniqueness_of :user ############## here is my model ###########3 class Customer < ActiveRecord::Base has_many :orders attr_accessible :first_name,:last_name, :zip_code,:user,:hashed_password validates_uniqueness_of :user ########################################## and when i run the application...