Displaying 20 results from an estimated 40000 matches similar to: "validation :on => :update...."
2006 Apr 26
0
Validation of params
As we all know you cannot trust anything you receive from the internet.
I am wondering what the correct RoR way is to solve this. For the model 
there are various validates_* methods that you can use to ensure some 
integrity of that part. That is good by itself. Though it would be nice 
if setting these would also result in enforcement in the database backend 
itself when supported. Here I am as
2006 Aug 14
2
Plugins: Validation Reflection and Client-Side Validation
I''ve just put two plugins on RubyForge. Included below are the READMEs. 
You can get the plugins at
svn://rubyforge.org//var/svn/valirefl/validation_reflection/trunk
svn://rubyforge.org//var/svn/clientsidevali/client_side_validation/trunk
Michael
Validation Reflection
=====================
Version 0.2, 2006-08-06
This plugin adds reflective access to validations
 -
2007 Nov 03
3
Birthdate validation
Hello everyone,
I''m almost cracking my head trying to do this birthdate validation. It
turns out that I can only accept users with at least 18 years old and
I''m trying to validate it writing this code on my user.rb fil at app/
models
class User < ActiveRecord::Base
	validates_presence_of :full_name
	validates_presence_of :street_address
	validates_presence_of :city
2006 Apr 21
4
Dynamic Menu
Hi, I think I''m doing this the right way, but can''t get it going.  I''m 
building a menu from the values in a mySQL table, and want to build it 
on the fly.  This is something that should be working but only works 
halfway:
<% @pages = Page.find(:all, :conditions => [''site_id = 4'']) %>
<% @pages.each do |p| %>
	xyz
	<%p.id%>
<%
2005 Dec 17
0
bug? saving (valid) updated object results in validation error
Hi!
I have an error that I don''t understand. It shouldn''t be happening,  
according to the documentation! I have a class, defined as below.
> class Coupon < ActiveRecord::Base
>   belongs_to  :product
>   belongs_to :account
>   validates_presence_of :product
>   validates_associated :product
>   validates_presence_of :voucher
>   validates_presence_of
2006 Jun 21
3
validation help
I would like to validate a number within a certain range.
To first test that a entry is a valid number i use
validates_numericality_of :my_number, :message =>''sorry, not a number''
to test if the number is within a certain range i use
validates_inclusion of :my_number, :in => min..max, message => ''outside 
range!''
If the numericality test fails, I
2006 Jul 08
1
overriding validation messages
I have the following in my model
validates_numericality_of :lwind_id
When a user submits a non numeric value for the lwind control, the default 
validaiton message is "Lwind is not a number".  I need this to say "Land 
Window is not a number". 
I have placed the following in my model
validates_numericality_of :lwind_id, :message => "Land Window is not a 
2006 May 31
1
ActiveRecord: When / where to validate data? Tricky question
First of all, thanks for you time. I have kind of a tricky question and 
wanted to see what you guys thought.
-------------------------------------------
Lets say I have this:
-------------------------------------------
class Purchase < ActiveRecord::Base
  validates_numericality_of :some_number, :only_integer => true
end
-------------------------------------------
Then I do this:
2007 Jan 18
2
Conditional validates_inclusion_of execution problem
All,
I have a field that I''m validating with validates_numericality_of on as
well as validates_inclusion_of, like so:
validates_numericality_of :number_of_owners,
                          :only_integer => true,
                          :message => ''must be a whole number''
validates_inclusion_of :number_of_owners,
                       :in => 1..3,
        
2006 Aug 01
0
Validation of facade columns
I''m having difficulty understanding how to make validation of facade
columns consistent with validation of other active record columns. To
illustrate this, I''m going to extend the facade column example
discussed on pp. 284-5 of AWDR. Let''s say that there is a "rectangles"
table that has width and height columns. For some unknown reason,
width is stored in
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 Jan 30
1
Either/Or Validation
How would I use validations to ensure I either received a blank value or 
a ten digit number?
If I set validates_length_of :field, :in => 0..10 then that would allow 
any value in-between.  The allow_nil => true option does not seem to 
work.
I''ve also tried using this with some combination of 
validates_numericality_of but cannot get it to work.
Any help would be greatly
2009 Nov 20
3
Ensuring that foreign key is valid
I am trying to set up a validation in a model to ensure that a record
can''t be saved unless the foreign key it belongs_to is a valid record.
My model says:
    class Admin < ActiveRecord::Base
	validates_presence_of :user_id
	validates_numericality_of :user_id
	validates_uniqueness_of :user_id
	validates_associated :user
	belongs_to :user
    end
but I can still create an admin
2006 Jun 07
1
Validating numericality based on related attribute value?
I have a price attribute in my model which I need to validate as a
positive number if the attribute price_terms.requires_value is equal to
''Y'', otherwise price can be blank or zero.  Price_terms is a select list
which my model table belongs_to.
How do I do this? - I tried doing this:
validates_numericality_of :price, :if =>
self.price_term.requires_value.upcase ==
2007 May 01
2
Problem validating boolean
Hi
I''ve got a problem validating a boolean and I can''t see what the  
problem is.  Here''s my model:
   class FinanceAgreement < ActiveRecord::Base
     belongs_to :asset
     validates_presence_of :finance_company
     validates_inclusion_of :balance, :in => 0.01..10_000_000
     validates_inclusion_of :term, :in => 1..600
     validates_numericality_of
2006 Jul 11
1
Validating composed_of
Hi,
How do I validate a composed_of attribute in my model?
I have a product model with:
	composed_of :price, :class_name => ''Money'', :mapping => %w(cents cents)
	
This maps the price attribute to the Money
(http://dist.leetsoft.com/api/money/) class. I want to make sure that
the price only contains a price to 2 decimal places i.e. 1.25. This is
because if someone enters
2010 Feb 10
6
validation problems
Hi, there.
I have two validations in the model:
validates_numericality_of :value, :only_integer=>true,
:allow_blank=>true
validates_size_of :value, :is=>9, :message=>"must be 5-digit number",
:if=>Proc.new{|u| u.value.is_a?(Numeric)}
They work as expected except when the :value is character/string like
"a" "abc", the second validation will also output
2008 Jul 17
2
problems with validation on STI
I have the following STI table:
def self.up
    create_table :distributions do |t|
      t.string :type
      t.integer :simulation_id
      t.string :dist_name
      t.string :desc, :default=> ''fixed''
      t.float :param1, :default => 5.0
      t.float :param2, :param3
      t.timestamps
      #fields for RscDist
      t.integer :resource_id
      #fields for LoadDist
2006 May 30
1
Not working validation
Hi there,
I have some model classes where I''ve tested successful that validation 
worked. After some more days of iterations I found that that validation 
isn''t working anymore. The validation functions are not even called. 
Example:
class Company < ActiveRecord::Base
	validates_uniqueness_of :name
	validates_numericality_of :money
	
	validates_each :money do  |record, attr,
2006 Apr 07
13
Pop up menus - any ideas?
I''ve got a menu in which I have all of my categories as links. Each 
category also has subcategories. I want to set it up so when you mouse 
over the category the subcategories will pop up (to the right of the 
main list, but that''s just CSS). This is what I have so far:
<% for category in @categories %>
	<a href="#"