Displaying 20 results from an estimated 5000 matches similar to: "Rails validation - newbie"
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
2006 Jun 10
2
regex help
I am trying to write a model validates_format_of that will accept a
field containing only certain characters. I want the field to only
allow the following characters:
a-z, A-Z, 0-9 and the ''_'', ''@'', ''.'' and ''-'' characters.
I have hunted around a bit and came up with this:
validates_format_of :password, :with =>
2005 Jul 19
1
Nested drag and drop rendering issue with ie
First and foremost, excellent library - excellent work. Thank you.
Now, here''s what I''m doing:
<div id="wrapper">
<fieldset id="page_1">
<legend>Page</legend>
<fieldset id="group_1">
Group
</fieldset>
<fieldset id="group_2">
Group
</fieldset>
2006 Oct 11
2
Help please with observe_form - not working
My observe_form is basically totally limp. I think it should update without
hitting submit button but even if I hit it , it doesn''t change (doesn''t seem
to post the data).
Can anyone please take a look and see if I"m doing something wrong. TIA
Form:
<% start_form_tag({:action => "livesearch"},
:id => "asearch") %>
2007 Apr 23
3
getElementsBySelector problem in IE
I''m having this problem with IE and getElementsBySelector, but am a
relative js novice, so quite possible -- likely even -- that I''m doing
something stupid. Either way, a fresh pair of eyes would help.
Basically I''m duplicating a fieldset within a form (so you can upload
more than one photo). [BTW, the fieldsets have a CSS id which relates
to the object id of the
2008 Jun 07
3
DRY validates_format_of?
In a model I have following validates_format_of. Is there an easy way to
DRY this up? It seems to be rather repetitive.
validates_format_of :expiration_date, :with =>
/^[0-9]{4}[-][0-9]{2}[-][0-9]{2}$/
validates_format_of :activation_date, :with =>
/^[0-9]{4}[-][0-9]{2}[-][0-9]{2}$/
validates_format_of :some_other_date, :with =>
2006 Jul 07
2
Problem with GetText 1.6.0 - undefined method ''N_''
I''m just upgraded GetText from 1.4.0 to 1.6.0, and all my tests got broken.
I got this error:
ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/base.rb:1129:in
`method_missing'': undefined method `N_'' for User:Class (NoMethodError)
etc
My model user.rb has this line:
validates_format_of :login, :with => /^[a-zA-Z0-9_]+$/, :message =>
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 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
2009 Feb 15
2
Collapsible Fieldset
Hey there,
(First steps in Ruby and Rails...)
I''m trying to make a fieldset collapsible, like they are, for example,
on many Drupal pages.
What I''ve figuared out is the following:
<fieldset id="addressdata" class="collapsible collapsed">
<legend>
<%= link_to_function("Show/Hide Addressdata") { |page| page[:
2012 Aug 14
3
validates_format_of :message not working, validates_length_of :message is working
I''m using validates_format_of and the validation I want to do works, but I
can''t get an error message to be displayed if the data is invalid:
validates_format_of :mobile, :with => /\A[\+0-9]+\Z/, :message => " - Wrong"
I have another validation some where else that does display the error
message: " - Name is too long"
validates_length_of :name,
2012 Jan 11
4
Observe field with jquery in Rails 3.1
I tries to observe a change in a field with jquery in Rails 3.1 in
order to be able to implement two cascading select boxes.
A a first step I just try to observe a click in a div using jquery
I have the following function in a .js file that is loadedin the head
section (fieldset is the id of a div) and is displaying a view with
the div fieldset
$(document).ready(function() {
2007 Nov 06
2
Why is this view spec failing?
I can''t figure out why I am getting a failure. It renders out fine in
the browser.
<h1>New member</h1>
<%= error_messages_for :member %>
<% form_for(:member, :url => members_path) do |f| %>
<fieldset>
<legend>Member Info</legend>
<p><label for="member[first_name]">First Name:</label> <%=
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.
2007 Sep 06
1
semi-nube help request
just to show i''m not a complete dork: i receive emails from the list through
gmail and i''ve already searched for the answer to this problem and since
i''ve been a member i''ve not received an email about it. Google search
results are mixed at best.
so this is my problem:
i have a form:
<div id="container"
2010 Aug 17
2
[Form] Method POST & PUT problem
Hello,
I have a form that should be a POST method, but Rails insist to put a
hidden field "_method" that has the value "put" does anyone knows why?
Thanks,
David Sousa
Controller: -------------------------------
def new
@user = @current_user
end
-------------------------------------------
View: -------------------------------------
<% semantic_form_for @user,
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 Apr 05
4
validates_format_of ?
Hi all,
I''ve got a form which accepts a "price" field and I''m attempting to
validate it and allow some flexibility in the way the user enters it.
It''s a numeric field but I want the user to be able to enter dollar
signs and commas naturally in the data entry.
I''m trying to understand how to use validates_format_of, and I''m not
sure what
2006 Jul 28
1
Nasty pitfall: don''t use ^ and $ in validation regexes!
Let''s say you want to validate that an attribute contains only 2-10
lowercase characters, e.g. with validates_format_of. The appropriate
regex is obviously /^[a-z]{2,10}$/, right?
Wrong! Try it with "abc\nANYTHING YOU LIKE" - this is perfectly valid.
On the second look the reason is clear: ^ matches the start of a line, $
matches the end of a line. So as long as one line in