Displaying 20 results from an estimated 3000 matches similar to: "Blank fields getting validated"
2008 Oct 25
7
Routing of result not clear in ActionMailer
Dear all,
I am trying to understand the following behaviour of the ActionMailer
in Rails 2.
I have an emailer_controller.rb
class EmailerController < ApplicationController
def send_mail
Emailer::deliver_contact_email(params[:email])
end
end
I have a model emailer.rb
class Emailer < ActionMailer::Base
def contact_email(email_params, sent_at = Time.now)
@recipients =
2007 Mar 29
4
validates_length_of not working with :if ?
Hello,
I''m trying to cut down the errors if the guy already getting the empty
nickname, so he doesn''t get anything about the nickname is short.
validates_presence_of :nickname
This below is not working ?
validates_length_of :nickname, :within => 4..40, :if => Proc.new {
|user| user.nickname.length > 1 }
nor this one below?
validates_length_of :nickname, :within
2006 Aug 11
5
Unit tests - NilClass problem
Hi!
Yesterday I started to write my unit tests for the fist time using
rails. I''m using this method:
http://blog.codahale.com/2005/12/23/a-rails-howto-simplify-your-unit-tests/
My customer_test.rb looks like this:
require File.dirname(__FILE__) + ''/../test_helper''
class CustomerTest < Test::Unit::TestCase
fixtures :customers
# Replace this with your real
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 Dec 15
4
Why won't Rails update my object attributes?
Here''s the issue: When I submit a form for updating,
@person.update_attributes doesn''t work. But the next nested clause for
updating images DOES work. How is that possible? However no matter
what I do the Person object will not change its attributes.
def edit
@person = Person.find(params[:id])
if request.post?
@person.update_attributes(params[:person])
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 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
2006 Feb 28
6
How To Validate Boolean Form Field
Hello all.
I''ve got the following in my model:
class Individual < ActiveRecord::Base
validates_presence_of :first_name, :last_name, :street, :city,
:state, :zip
validates_acceptance_of :AZ_resident, :message => "You must be an
Arizona resident."
end
The AZ_resident field is present and defined as boolean (PostgreSQL
8.1), but validation will not occur.
2007 Jul 06
2
validations of "type" when using Single Table Inheritance
Sorry if I''m just dumbing out, but is there a reason that when using
Single Table Inheritance Rails doesn''t really validate the "type"
field or provide some mechanism to do so? seems like a good way to
corrupt a database. Because the "type" is also a special attribute, I
had to resort to an ugly hack like:
class ActiveRecord::Base
def type_attr
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/.
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/.
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
2007 Jul 24
13
Problem with validates_length_of an integer
Hello guys, I''m trying to validate the input of an integer from a form,
here is a bit of code:
This is the definition of the offending column in the migration:
t.column :position, :integer, :default => 0, :limit => 3, :null => false
And here is how I try to validate it inside de model:
validates_length_of :position, :within => 1..3
And this is the exception I get when I
2007 Dec 27
4
validates_file_format_of only when is there an image
i have a model with this:
file_column :image
validates_file_format_of :image, :in => ["gif", "png", "jpg"]
If inthe form the user not insert the image i receive an error.
If i remove:
validates_file_format_of :image, :in => ["gif", "png", "jpg"]
it works.
Is possible do the validation only when user insert the image in form?
i
2006 Feb 14
2
confusion with validates_inclusion_of
It appears that if your trying to use validates_inclusion_of for a
string value allow_nil wont work. For example, if I have an attribute
:year which is stored as a varchar then:
validates_inclusion_of :year, :in => "1980"..Time.now.year.to_s,
allow_nil=>true
will successfully validate the range but will not allow an empty input
field to be submitted. However, if :year is
2005 May 04
1
Conditional validations
I''ve been working with the problem that Joe Hosteny has been talking
about on this list and on the tickets he''s posted
(http://dev.rubyonrails.com/ticket/1196) and have come up with a
tentative solution that I''d like to bring up here.
What if we use a "conditional" parameter in the validates_* methods?
Here''s how it would look like in practice:
2007 Jan 29
8
Cluster 3 mongrel servers residing in different machines (Windows)
Hi All,
Machine A: has Apache 2.2 doing load balancing, also has DB and 8
mongrel processes I''m using mongrel_cluster . Now, I want to run
Mongrels on Machine''s B and C (ie Cluster 3 Mongrels in three
different machines). Is this possible? If possible then, please
describe me the steps required (I''m using windows machines, and
already losdt one week :-( )
Best
2008 Nov 21
15
Switching the version of Rails that an app uses
Hi All,
I’ve got a few versions or Rails installed and I''d like to run an App
I’m developing with various versions of Rails. I heard of two ways to
switch the version of Rails that an app uses:
1. Use GitHub as described by http://kylecordes.com/2008/04/30/git-windows-go/
. But that requires using Bash in a Command Window and more steps
than I want to go through.
2. Alter
2007 Mar 13
7
Form with subforms
Hi,
I''m looking for a way to implement subforms. For example, a form where
you can add clients, and at the same time enter contactpersons for
this client.
I''ve been looking around, reading ebooks, etc, but can''t seem to find
a good example/tutorial for something like this. So I would be very
thankful if someone could point me in the right direction.
Thanks,
Sven
2006 Jun 15
6
Newbie''s problem with a nil object he didn''t expect!
Dear Rubyists/Rails gurus,
Though I''ve successfully completed the various Rails tutorials online
and the Depot application from the Agile Web Development with Rails
book, I''m still pretty much a Ruby/Rails newbie. I''m trying to learn by
writing my own simple blogging application, but I''ve run into a problem
that has had me scratching my head for a few days now.