similar to: boolean db fields set to false fail validation with validates_presence_of?

Displaying 20 results from an estimated 6000 matches similar to: "boolean db fields set to false fail validation with validates_presence_of?"

2009 Jan 12
2
validates_presence_of fails with false boolean
This almost feels like a bug to me, since false is not nil. (i don''t think!) Using v_p_o on a boolean field fails validation if the field is passed with ''false''. It passes validation in the case of true. How can I validate _presence_of a boolean if it is submitted false? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~
2007 May 11
4
"validates_presence_of" not working
Hi, guys, I''m learning to use Rails, and, while reading the "Rails: Up And Running" book, I tried to make an insertion validation, using the following code: class Photo < ActiveRecord::Base validates_presence_of :filename end It simply didn''t work, the validation does nothing and an insertion with an empty field returns TRUE. What''s wrong?
2007 Jun 21
1
Validation Through Multiple Models from one Form
Hey All, I have a form that submits data to multiple models. I have class Man < ActiveRecord::Base has_many :notes has_many :contacts validates_associated :contacts, :notes validates_presence_of :first_name validates_presence_of :last_name class Contact < ActiveRecord::Base belongs_to :man validates_presence_of :contact_info class Note < ActiveRecord::Base
2007 Nov 29
4
collection.build or collection.create gives "ArgumentError: wrong number of arguments (1 for 0)"
I have a Project that has_many Tasks. Tasks belongs to a Project. When I try the following: project = Project.new project.tasks.build I get: >> s = Project.new => #<Project:0x25f9e28 @attributes={"name"=>"", "end_at"=>nil, "updated_at"=>nil, "published_at"=>nil, "user_id"=>nil,
2006 Jul 12
5
validates_peresence_of
Is there an expert validater that can point me in the right direction? I''ve looked for extended documentation on ''validates_presence_of'' but i can''t seem to find any. I''m trying to make sure that i don''t enter a nil object in my database, so i''ve added validate_presence_of to my Record Model. i.e. --> class Record <
2007 May 11
5
options_for_select - how to set the selected value?
Ok, this should be simple but I am finding it''s not and previous postings don''t seem to shed too much light on this. I have a select_tag with 4 values pulled in via a helper: def filter_hours filter_hours = [ ["1 hour", 1], ["24 hours", 24], ["7 days", 168], ["14 days", 336], ] end The select_tag looks
2006 Jul 17
19
updating model
hello, i am writing a simple user login system. when registering a user account, i have two field: password password_confirmation which are validated using validates_presence_of validates_confirmation_of and these are then used to generate a password hash which is stored in my database when i want to update the record (without changing the password and entering new values for password and
2006 Aug 16
0
validates_presence_of non-null float/boolean/integer fields
Has anyone figured out a way to get validates_presence_of to work with float, boolean, and integer fields that are defined as non-null in the schema? The problem is, ruby intializes these types to the default schema value, which for mysql is never null if the column is not allowed to be null, and as a result they are initialized in the form with a value, and are never null. I found a work
2006 Apr 12
11
validate_presence_of not working for me
Hi all, I just begun with RoR and going through the Agile development w Rails depot example ATM. I did everything according to the book (i believe), and after 3 hours of googling, reading docs, making sure i did everything correctly i can not make the validate_presence_of() to work - at least not as it looks in the book. My Product model looks like: class Product < ActiveRecord::Base
2006 Jan 17
2
change error messages for Validation helpers?
Is it possible to change error messages for Validation helpers? I am writing an app against a existing database (so no control over column names), but when there is validation error (e.g. with validate_presence_of) I would like to customize the field name. For example for telephone whose field name is PhoneNumber I would like to chnage it to "Telephone Number cannot be empty" rather
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
2007 May 08
3
How to restore fields ("validates_presence_of")
Hi all, I am using "validates_presence_of" for validating all fields of my registration form. It is working fine and generating custom error message as mentioned. Also clearing all fields. How can restore those fields which are already filled. Problem is "validates_presence_of" clearing (blank) field if it fails, instead of restoring fields which are already filled. Help.
2006 Mar 25
3
validates_presence_of validation order?
I have a form with 3 fields: user_id, email and password. All 3 fields are required, so I have a "validates_presence_of :user_id, :email, :password" in my model. Works, but the validation errors show up in a different order than I specificed in the validates_presence_of statement. Is there a way to specify the order in which the validations (and corresponding error messages) should
2006 Feb 10
1
Bizarre ActiveRecord::Errors/validation problem
I could be going mad and missing something really obvious here but I''m getting an unexpected result from the following. The schema: create_table :services, :force => true do |t| t.column :id, :primary_key t.column :name, :string, :ilmit => 5, :null => false t.column :port, :integer, :null => false t.column :status, :string end The model: class Service <
2007 Dec 22
3
collection_select validation problem
I''m trying to assign a parent foreign key value using collection_select from my child "new" form. The problem I''m having is if I do not make a selection, I get the following error instead of the Rails validates_presence_of error: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating
2006 Jul 06
2
Validation Error
Hi all, I''m trying to validate a data field. I''ve added ''validate_presence_of :name'' to the record model, but when I try to create a record i get an error complaining that it can''t find data from another table that also is updated on that page. Let me explain further, On my ''record'' update page, I have data from another table
2006 Jun 13
7
model validation across multiple views
I have a rather complex object with a number of attributes. For a variety of reasons, I would like one view to create the object with only a couple of fields completed, then a second and third view to finish all the fields. I would like the model to validate_presence_of all these fields, since eventually I need them all there, and I would like each page to validate its portion of the fields that
2013 Nov 14
6
validates :boolean_field, presence: true misconceptions
Last night a friend of mine started ranting about validates_presence_of :boolean_field returning not valid when the boolean field is false. I checked the rails issues and this seems to be a pretty common concern about the naming of ''presence'' . Instead of changing the behaviour of the presence validator, I was wondering if maybe the answer to avoid such misconceptions could be
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 Mar 13
4
undefined method `validates_presence_of'' for #<ProductsContr
Hi, I am trying to use method `validates_presence_of'' for validating my input fields on form . I m using it in my action class as follows:- ======================= validates_presence_of(params[:product][:quantity]) ====================== But when I am running my application i m getting error like:- ========================= undefined method `validates_presence_of'' for