Displaying 20 results from an estimated 8000 matches similar to: "high-level validation : error messages order"
2006 Apr 14
1
Validating Existing Models
I''ve got a user object which has quite a few attributes mapped to the
database. As of right now I''ve got some validations in the model like:
validates_presence_of :password, :message => "You must specify a valid
password."
validates_confirmation_of :password, :message => "Password doesn''t match
the confirmation."
validates_presence_of
2006 Mar 14
4
validates_confirmation_of has stopped working
Hi Railers,
I''m past considering myself a noob in Rails land - I think what I''m up against
here is more of a bug or an anomaly that I''m unaware of (or that has changed
in a recent version).
I had a fully working validates_confirmation_of :email_address field in my app
- was one of the first things I set up, extremely simple, been working for a
long time.
Then one
2005 Dec 29
7
belongs_to causing NoMethodError exceptions ... ?
I''ve got a really strange problem using belongs_to. I apologize in
advance for the length... this is going to take a while to explain.
Basic idea: Creating a User requires that the user enter an email
address and activation key that matches an existing PendingUser.
After creating the user successfully, that pending user should be
marked as "used".
The problem:
When I
2006 Feb 21
1
Custom forms and fieldWithErrors tags
Hi,
(probably) A newbie questions:
I have a form where a user can choose an email address, but there are only
some choices for the domain, so I wrote a helper where the local part of the
email is a text field and the domains is a dropdown list, like:
Select Email: [ my_name ] @ <domain.com>
..which I defined as a helper:
def email_form(tagname, domain_list)
2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come
in. Console just gives me back :account_id => nil. Obviously I''m trying to
set it though. Silly console...
But, I can set the account_id column in my controller like so:
@user = User.new(params[:user])
@user.account_id = account.id
@user.save
Here''s what I give to the controller:
User.create :name
2007 Nov 03
3
Birthdate validation
Hello everyone,
I''m almost cracking my head trying to do this birthdate validation. It
turns out that I can only accept users with at least 18 years old and
I''m trying to validate it writing this code on my user.rb fil at app/
models
class User < ActiveRecord::Base
validates_presence_of :full_name
validates_presence_of :street_address
validates_presence_of :city
2006 Apr 13
1
Model is not a class
I''m trying to specify a model in a controller, but rails gives me
"Account is not a class", where Account is my model name ...
This is my model:
class Account < ActiveRecord::Base
validates_presence_of :email, :email_confirmation,
:username, :password, :password_confirmation
validates_format_of :email,
:with =>
2007 Mar 09
2
Blank fields getting validated
Hi,
I am not sure if this is already answered in this list. I couldn''t
find an answer. So I am posting the question.
I have multiple validations for a field. For example:
validates_presence_of :contact_email
validates_format_of :contact_email,
:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,
:message => "is not a valid email
2006 Jan 12
1
A really newbie question
Hi,
I have been playing around with Ruby after reading so much about it, and
so I started tweaking with auto generated scaffold.
But it seems like I must be missing something, can someone else please
help me take a look and give me a couple pointers? In short I was trying
to make a class User that has a method addupdate with 2 parameters
(alias and email) which would either update the
2006 Jun 13
0
HTTP validation regexp, possible solution
There was an old email thread from the end of January 2006 discussing
regular expressions for matching URLs. I took some of the sample
expressions and tweaked them a bit to the point where I think they
are pretty useful. They pass all of my tests anyway. :-)
For a reminder, here''s a sample message from that thread. My code is
below it.
On Jan 26, 2006, at 5:28 AM, Nathaniel S.
2008 Apr 22
0
rspec model class methods
I''ve started specifying a project and could use some help. I''m not sure
if the spec is entirely necessary, it would be great to get some
guidance on a best practice or something close.
I recently realized the need to add the method below grouped_by_months
and started to write a spec.
idea 1:
{{{
before do
@comment = Comment.new
2005 Dec 17
1
How to use validation with aggregation (composed_of)?
At the risk of being banned for posting the same question twice, I
thought I''d try once more with a question for the title rather than a
statement (on the basis that perhaps questions get answered and
statements ignored ;-) )
ActiveRecord supports composed_of for value objects which is
fantastic but one thing that it doesn''t seem to support (or at least
I am unable to
2005 Dec 16
4
Validation with Aggregation
ActiveRecord supports composed_of for value objects which is
fantastic but one thing that it doesn''t seem to support (or at least
I am unable to find any documentation for) validation of the value
objects.
For example, given the following:
class Message < ActiveRecord::Base
composed_of :sender, :class_name => ''EmailAddress''
composed_of :recipient,
2007 Aug 07
2
Making Validations Optional
Hello,
I am working with URL validations. I want this validation to be
optional if the data exists in the form submission. I have tried
several things.
validates_format_of :website,
:if => params[:organization][:website],
:with => /((http|https):\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]
{2,5}(([0-9]{1,5})?\/.*)?/,
:message => "Please enter a valid url"
Of
2006 Jan 20
4
validates_format_of > Invalid regular expression with simple pattern
Hello,
I try this :
validates_format_of :name , :with => /^[A-z0-9_.- ]*$/ , :message =>
"bad characters"
for accept any name with chars "A" to "z" , "0" to "9" , with "_" "."
"-" and " "
The pattern is really simple but I have this error :
SyntaxError in Login#register
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,
2009 Sep 19
1
validations on a field
hi, i have a model with 2 validations on a field
example:
validates_presence_of :email
validates_length_of :email, :within => 6..100 #r@a.wk
validates_uniqueness_of :email
validates_format_of :email, :with =>
Authentication.email_regex
if i do the submit of form for a new object of the model with a blank
mail
i receive 4 errors.
In this case i want receive
2006 Sep 10
1
validates_format_of :something, :with => /REGEX/
Hi all,
I''m hoping to stir the Rails pot a little bit here, so please go easy
with me ;-)
Regular Expressions is the most densely inhumane language construct
ever invented in any ''civilisation'', and the fact that we still have
to dirty our minds with this in Rails is something that (sh/c)ould
ideally be corrected in Rails (preferably before the release of 1.2
2005 Nov 28
4
validates_format_of nil
I''ve noticed that validates_format_of will return invalid if the field
is nil.
Question 1) How should we declare a validation that will validate it
with a regex if it is set, but, if the field is not set, just move on
Question 2) Why is it done this way? The other validators are only
invoked if the field is set . If you want to declare the field
mandatory, you add a
2006 Jan 22
0
Validation on composed_of problem
I am having problems with this:
validates_presence_of :amount
validates_format_of :amount, :with => Money::PATTERN, :allow_nil =>
true
composed_of :amount, :class_name => Money, :mapping => [[:amount,
:to_s]]
The problem is when I use this field in a form, and the text is blank,
ActiveRecord gives me two errors:
"money is invalid"
"money