similar to: validates_numericality_of and greater_than* doesn't appear to be working

Displaying 20 results from an estimated 7000 matches similar to: "validates_numericality_of and greater_than* doesn't appear to be working"

2008 May 17
12
validates_numericality_of with greater_than* less_than* simply don't work
It seems that the validations for: greater_than greater_than_or_equal_to less_than less_than_or_equal_to equal_to odd even Simply do not work (Rails 2.0.2). I''ve tried every combination I can think of and these never seem to fire. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2011 Jun 19
10
validates_numercality_of with allow_nil.
In the model I have: validates :square_meters_public_land, :barrier_meters, :numericality => { :greater_than_or_equal_to => 0 }, :allow_nil => true but if, in the field, on create, I don''t insert a value I have the error "field is not a number". -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To
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:
2006 Apr 03
4
validates_numericality_of, :allow_nil => true?
Is there a way to use validates_numericality_of and still allow null values? I have a model with some optional values that can be nil, but if they''re present, they must be numbers. Will I need to construct a custom valiation for this, or is there some method built in? Seems like it would be a common enough need. Jeff -- Posted via http://www.ruby-forum.com/.
2011 Sep 04
0
should validate_numericality_of with greater_than_or_equal_to
Hello, I have this in my spec it { should validate_numericality_of(:amount).greater_than_or_equal_to(0) } but I get error: Failure/Error: it { should validate_numericality_of(:amount).greater_than_or_equal_to(0) } NoMethodError: undefined method `greater_than_or_equal_to'' for #<RSpec::Matchers::Matcher:0xef23150> this page
2006 Aug 14
1
What fields_for really for?
Hello everyone! I have 3 models: === 1 === class Region < ActiveRecord::Base has_many :districts end === 2 === class District < ActiveRecord::Base belongs_to :region has_many :suburbs end === 3 === class Suburb < ActiveRecord::Base belongs_to :district validates_numericality_of :region_id, :only_integer => true end In edit.rhtml for SuburbController I need to specify
2013 Sep 07
0
[shoulda-matchers gem] validate_numericality_of_matcher strange behaviour
Hello I have Vacancy model and vacancy_spec test with validates_numericality_of :salary, greater_than: 1 in the model and validate_numericality_of(:salary).is_greater_than(2) in the _spec. When i run rspec spec command tests pass (in some cases and in other they don''t) Why? vacancy.rb ------------------------ class Vacancy < ActiveRecord::Base validates_presence_of :name,
2009 Jun 24
2
At my wits end ! Controlling passed in negative values from a form
Hi, I am trying to validate a numeric value passed in from a form, which is saved in a MySQL db as decimal(9,2) Now problem is I need to ensure people don''t enter a form value like -. 003. In my validations, I have a validates_numericality_of check being done. Furthermore, in validate method, I have a check using an if statement such as : ((an_object[n].nil? or an_object[n] < 0) and
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 Apr 27
0
DRY validation
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, A few months ago someone posted a message about specifying validates_* constraints on a per-attribute basis. I just created a small plugin that allows you to do this. Here''s an example from one of my models: class Country < ActiveRecord::Base attribute :name, :string do |a| a.validates_length :within =>
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 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
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 Mar 28
0
Patch review request: validates_numericality_of does not replace option in custom message like in default message
Hi, Today someone created a ticket for a defect in validates_numericality_of, at first sight i thought it wasn''t a defect but an enhancement. But then i found that validates_length_of accepts :message => "should be greater than %d", but validates_numericality_of doesn''t (The output for v_n_o is: "should be greater than %d" instead of "should be
2010 Aug 18
7
error_messages_for doesn't work
I''m having a problem, ''cause I wrote the following line in my model "Hi": [code] validates_numericality_of :phone, :only_integer => true, :allow_blank => false, :message => "must be a number" [/code] And in my "new" view, I put: [code] <%= error_messages_for :oi, :header_message => "Erro ao cadastrar
2008 Feb 12
0
Validate all model fields with validates_numericality_of
hi, I have a rather big table and i need to validate every decimal field in the table to make sure its numeric. Can anyone think of the best way to do this or is it even possible? I dont want to write validates_numericality_of: and then each field in the table seperately. JB -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this
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 Jun 07
1
Setter that converts a float attribute to integer
Hi, I have some problems with an application where I''m using custom accessors to do currency conversions. In my model, I have a price attribute in the database that stores the value in cents, to avoid future problems with float arithmetic and round. But at the views, I would like to show the price in euros, with decimal for the cents. So I defined a new attribute called price_in_euros,
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 19
7
validates_numericality_of positive integer
Hi, What is the simplest way to validate a positive integer? validates_numericality_of :foo, :integer_only => true how do I add the positive part? Do I need another validation statement for pattern matching or do I have to write a validate() funciton for my model? Thanks, Peter