Displaying 20 results from an estimated 50000 matches similar to: "validates_presence_of validating twice?"
2007 Oct 17
16
rspec causing validates_presence_of to validate twice?
I had posted this on the regular Rails list, but upon trying this in
script/console, it seems like the behavior only exists when running rspec.
I''m getting some weird behavior in one of my models. I have a model
defined something like this
class User < ActiveRecord::Base
attr_accessor :password
validates_presence_of :password
end
If I validate the model without specifying a
2008 Jul 06
1
ActionView::Base.field_error_proc not getting an error field
In my User form I have standard field to get user record attributes
(first_name, last_name and email)
I also have a select drop_down to choose a role from an array
first_name, last_name and email are user record attributes, but I
defined the role name as a virtual attribute
validates_presence_of :email, :last_name
attr_accessor :role_name
validates_presence_of :role_name, :if
=>
2008 Nov 01
2
stuck on a validates_presence_of unless issue
i have a person object. Persons don''t need to have addresses, but if
they have any address field value, they must have them all. So I have
something like this:
validates_presence_of :street_address, :city, :state, :postal_code
unless :address_blank?
address_blank? checks whether all of the address fields are blank.
If I run a test like this, it works:
describe "given
2007 Oct 23
11
validates_confirmation_of not working?
I just can''t get validates_confirmation_of working for the life of
me!...
It''s not the first time I''m having problems with it but I just never
understand why!... This time I pretty much followed *exactly* the
example in Agile Rails Development and still...it just won''t work! I put
2 different passwords in the form and it doesn''t trigger an error,
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 Oct 26
0
Recipes authentication & validates_presence_of
I''ve implemented Rails Recipe #31, Authentication, and I found that
validating password and password_confirmation just doesn’t work while
the method ‘password=(pass)’ is in the mix, but I need that for the
salt/hashing, no?
If I don’t use validations, the password gets hashed, salted and stored
in the database fine. I can login with same username/password.
However, if I want to
2006 Aug 14
3
validating required fields during an update?
I have a User model with an email attribute. I''m using the following
validations:
validates_confirmation_of :email
validates_format_of :email,
:with => RFC822::EmailAddress,
:message => "must be a valid address in the form user@domain.com"
validates_uniqueness_of :email, :message => "address has already
been taken. If you''ve forgotten your
2008 Aug 31
6
why's my course_duration being reset
Can''t get this?...I''m close I think, my calculation appears to be
working, but.... when i access duration = <%= @enquiry.course_duration
%><br> in my final view it''s blank.. course_duration is getting set to
null but works for the calculation?
controller..
----------
class EnquiriesController < ApplicationController
layout ''welcome''
2009 May 25
1
Help --- My phone number field saves blank
I have a phone field in my table.
But in my form i have two text boxes to get the phone number and the
country code like below
Enter country code ----- Enter phone code ------
In my table i have to save the phone code field after joining the above
values with "-" symbol.
Example => 0225-25874255
I dont have table field for country_code .
So i created like below
attr_accessor
2007 Feb 26
2
boolean db fields set to false fail validation with validates_presence_of?
I have a model that contains a :boolean field. In my view, I have a
simple select of Yes or No, which equates to true or false,
respectively. If I choose yes and save, everything works great. If I
choose no, my model fails validation as I have this set as a required
field using validates_presence_of. I have checked the log and it''s
definitely set to false, why would this fail validation?
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
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
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
2009 Jan 09
3
What is wrong with validates_presence_of :my_association ?
Category.has_many :products
Let''s say a product must belong to a category. I know it is recommended
to do the following:
class Product
validates_presence_of :category_id
end
But, as we all know, this is a pain for new records, meaning what if the
associated category is a new record?
I''ve been meaning to ask this, but what''s wrong with doing the
following:
class
2006 Sep 06
6
validates_presence_of question
Can I use validates_presence_of somehow if I want to check that at least
one of 2 fields is not empty?
Thanks,
Dmitry
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2006 Jan 03
6
Am I going too far or Rails is just confusing? was {validates_presence_of *_id attributes}
Thanks for the input Blair Zajac and Chris (Nolan and Hall), and for others.
If all of you have time, please follow this (the question still
relates to the previous posts by me):
I have provided full steps to reproduce the symptoms.
If it matters, I''m running Ruby 1.8.2, Rails 1.0, and MySQL 5.0.15 on
Windows XP Professional.
1. First, the setup
MySQL
-----
create database testdb;
2009 Jun 02
3
valdate_presnce_of email, :if => :validate_id + Factory girl
Hi
In the model I have User
attr_accessor :validate_email_id
validates_presence_of :email ,:if => :validate_email_id
Could anybody please tell me how can I define a Factory for the above?
Thanks in advance
Sijo
--
Posted via http://www.ruby-forum.com/.
2006 Jul 27
2
Creating multiple objects from form data
I''m in the process of creating a sign up form for an online application.
The form collects account info, company info, and then info for an
administrative user.
The method looks like this:
def create
@account = Account.create!(params[:account])
@company = @account.companies.create!(params[:company])
@user = @company.users.create!(params[:user])
end
However, this inevitably fails
2006 Jun 08
5
Field names in validators
Hi!
Is there a (simple) way to use alternative field names in validation
messages? For example, if I have a validator like this one:
validates_presence_of :email
how can I make it print a message like "E-Mail Address can''t be blank"
instead of "Email can''t be blank"? I can override the "can''t be blank"
part by using the :message
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?