Displaying 20 results from an estimated 1000 matches similar to: "validates_numericality_of, :allow_nil => true?"
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
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,
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:
2007 Nov 20
1
:allow_nil validation vs. blank?
I think I must be doing something wrong... when a form returns params
to the controller, empty fields appear to be returned as blank, not
nil. so what''s the point of an :allow_nil=>true setting on a
validation? it fails because blank is not the same as nil.
i would expect either returned empty fields to be nil, or :allow_nil
to really be :allow_blank. otherwise i have to do a search
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
2006 Mar 30
11
Capistrano/SVN: Deploying different database.yml for live?
Greetings,
Today I''ve been working out how to begin using Capistrano and so far I''m
impressed. Even in my situation, learning Rails and deploying to a
single server, it''s incredibly helpful. I do have one small question
though:
In using Subversion I''ve used the "ignore" feature to ignore my local
database.yml file, because my local database and
2006 Mar 10
2
validation null objects and objects with data
I have a model where initially, they we don''t insert an gov_id value
because it isn''t known.
The field is given a value of "" because it is on the form.
I then added code to the ''create'' method to set that value to nil if it
is blank which seems to be fine but then it fails this validation (if
NULL)
validates_length_of :gov_id, :maximum =>
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
2008 May 11
0
validates_numericality_of and greater_than* doesn't appear to be working
I''m using Rails 2.0.2 and I have been trying to take advantage of the
"validates_numericality_of" with the ":greater_than" option with
something like this:
validates_numericality_of :users, :greater_than => 0, :only_integer =>
true, :allow_nil => true, :message => "The number of allowed users
must be a whole number greater than zero."
But this
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
2006 May 05
6
rake rails:update
This question has been asked before, but I am still can''t run rake
rails:update. I get
rake aborted!
Don''t know how to build task ''rails:update''
My environment: FC4, Ruby 1.8.4, Rails 1.1
Any idea what to do?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 Feb 02
1
allow_empty instead of allow_nil
Is trhere any way how to support allow empty? Rails prefer empty string
than null for database and then validations with allow_nil fails.
--
Posted via http://www.ruby-forum.com/.
2013 Apr 03
1
validates uniqueness scope allow_blank/allow_nil -> validation error
I have this in a model:
class GenreBadge < ActiveRecord::Base
belongs_to :game, counter_cache: :genre_badges_count, touch: true
belongs_to :genre
validates :game_id, uniqueness: {scope: :genre_id}, allow_blank:
true
end
When I get one existing genre badge
genre_badge = game.genre_badges.first
genre_badge.game_id = nil
genre_badge.save!
It creates an validation exception:
2006 Mar 27
3
Enumerable?
Hi,
Can anyone please point me to some docs on Enumerable. I can''t seem to find
anything on how to use it.
Thanx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060327/0825d5e8/attachment-0001.html
2006 Apr 16
7
Problem running unit tests
I am running Rails 1.1.2 with Ruby 1.82-15. My database is Postgresql. I
haven''t had any problems generating models, migrations, using scaffolds, and
generally building and using my application, but I haven''t been able to get
testing to work. I initially just ignored the problem and kept developing,
but would like to add proper testing from here on out.
Currently when I type
2006 May 25
3
No joy for newbie Capistrano user
Hello,
I tried taking Capistrano out for a test drive and I can''t even get out of
the garage.
I am following the instructions here:
http://manuals.rubyonrails.com/read/chapter/98#page262
As well as Duncan Davidson''s Deploying Rails with Lighty:
Deploying Rails with
LightTPDhttp://duncandavidson.com/essay/2005/12/railsonlighty
Specifically, when I do:
rake remote:exec
2006 Apr 27
7
HTML Title
Hi there,
If I have an application.rhtml template what''s the best way to set
the contents of title element in the html -> head area of the
template to something set in the view for action in a controller. I
want to just have one template which renders the basic layout for all
pages and I''ve been scratching my head over this one for a couple of
hours now.
Any help
2006 Mar 18
4
Accessing overridden method
I have two model classes:
class Item < ActiveRecord::Base
belongs_to :channel, :counter_cache => true
validates_presence_of :channel
end
class Channel < ActiveRecord::Base
has_many :items, :dependent => true
end
In the Channel controller I have variable channel.items, an Array of
Items. I would like to use the Array find method. However,
channel.items.find() is a Rails
2006 Apr 18
7
freeze_gems to upgrade and SVN
Hi all-
I just decided to move from my 1.1.0 to 1.1.2. I had previously frozen
to 1.1.0 and therefore had all of rails in SVN in my vendor directory.
When I finally got rake freeze_gems to work, it blasted (rm -rf) my
vendor/rails directory and put a new one in there. This also blasted
all my .svn directories.
Is there some convenient way to do a freeze upgrade and play well with
SVN?
2005 Aug 21
8
validates_numericality_of
As far as I can tell "numericality" is not a word. Maybe this method
should be renamed.
--
R. Mark Volkmann
Partner, Object Computing, Inc.