search for: validates_exclusion_of

Displaying 13 results from an estimated 13 matches for "validates_exclusion_of".

2006 Jan 11
2
validator to ensure two fields are different?
What validator can I use in a model to ensure that my :username field is different from my :password field? I''ve tried validates_exclusion_of :password, :in =>:username but I get a rails error "an object with the method include? is required must be supplied as the :in option of the configuration hash" Thanks! Gary
2006 Aug 14
3
case insensitive exclusion_of
I have the following validation code, however it will allow variations in case. Like ''Admin'' and ''admiN'', etc validates_exclusion_of :login, :in => %w( admin ), :message => "is reserved for system accounts" how can I make this validation case insensitive? -- Posted via http://www.ruby-forum.com/.
2006 Jan 20
3
Is there a way to validate a model w/o saving it?
...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 validates_length_of :login, :within => 3..40 validates_confirmation_of :password, :if => Proc.ne...
2006 Mar 24
2
Where to put array to be shared across models.
Quick question: I have an array of reserved words that I want to share across most of my models so I can do something like this in the models: validates_exclusion_of :username, :in => RESERVED_WORDS, :message => "This username is a reserved word. Please choose another." Here is a sampling of the the array: RESERVED_WORDS = %w( blog blogs forum forums search login logout signup signout register help store ) Should I just subclass AR and then e...
2006 Jul 11
4
validates_unlike plugin
Validates Unlike Plugin (v 0.1) ======================== Validates Unlike plugin validates that the value of the specified attribute doesn''t match against the regular expression provided Class Contact < ActiveRecord::Base validates_unlike :comment, :with =>/html|http|onclick|onmouseover/ , :message => "comment can''t include: href,http,onclick,onmouseover."
2007 Jan 16
4
Subdomain Account Keys Best Practice
Hi all, I''m thinking of useing sub-domains as account keys, something I''ve played with previously. I have accounts and users, fairly standard, except that users can belong to many accounts, and accounts can have many users. So I figure I need to have an area on the main domain, that allows users to view their account memberships and things. Sort of like a dashboard for each
2009 Jun 22
4
modal validation not works
Hi everyone, i have 20 fields in users table. in my admin profile module the admin can modify his infomation. but only 12 fields he can able to modify. so in my controller if params[ :profileinfo ][:first_name] @profileinfo.update_attribute(:first_name,params[ :profileinfo ][:first_name]) end the above simply saves what i enter into the field.why it doesnot consider the modelvalidation.
2011 Apr 21
1
Rails 3 Foreign Domain routing - cannot get this to work!
...ode] # app/models/project.rb before_validation :cache_domain validates_uniqueness_of :subdomain, :cached_domain validates_uniqueness_of :cname_alias, :allow_blank => true validates_presence_of :subdomain, :cached_domain validates_exclusion_of :subdomain, :in => %w(admin blog), :message => "is taken" def cache_domain self.cached_domain = if self.cname_alias.blank? "#{self.subdomain}.#{APP_CONFIG[:domain]}" else "#{self.cname_alias}" end e...
2008 Apr 04
6
validates_numericality_of :not_equal_to
I have a situation in which I want to validate a number is not zero. Both positive and negative values are acceptable, just not zero. validates_numericality_of has an :equal_to attribute, but I don''t see a :not_equal_to. I have not yet been able to find anyone who has discussed this. I did find information about custom validators, so I am now using a custom validator to check the field
2006 Aug 11
4
date (age) validation
I have an application that requires users to be in a specific age group, or above a certain age. For simplicity sake lets say they have to be at least 18. This is my most recent attempt to produce the desired result: validates_exclusion_of :birthday, :in => Range.new(Date.today, Date.parse( (18.years.ago).strftime(''%Y/%m/%d'') )), :message => "does not meet Terms of Service requirements" " Date.parse( (16.years.ago).strftime(''%Y/%m/%d'') ) " works as expected in cons...
2006 Jul 05
2
Serialized object behaves weird
Hi! I got a class named EinsatzFilter which I serialized to session. Before saving to session it works afterwards I keep getting the message: "undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from ActiveRecord::Base inherited class. Code: class EinsatzFilter include ApplicationHelper attr_reader :personen, :monat, :projekte, :kunde
2007 Feb 16
13
negate the regexp in validates_format_of
Railsters: ActiveRecord''s validation system puts other database systems to shame. However, the newbies might not know how to write a regexp that excludes a match, instead of tests for it. Understand - I''m just asking this question to help them. I have been using Regexps since ''grep'' on Xenix! But the newbies here might not know how to do this:
2006 Jul 27
9
Introspecting validates_presence_of
Hello people, I''d like to detect whether an attribute of a model has vaildates_presence_of applied to it so I can automatically apply a mandatory (*) to the field...it doesn''t look easy...any ideas? Cheers, -- Dan Webb http://www.danwebb.net