Displaying 20 results from an estimated 60000 matches similar to: "when does validation happen"
2006 Jan 19
7
validates_numericality_of positive integer
Hi,
What is the simplest way to validate a positive integer?
validates_numericality_of :foo, :integer_only => true
how do I add the positive part? Do I need another validation statement
for pattern matching or do I have to write a validate() funciton for
my model?
Thanks,
Peter
2006 Jul 21
10
why validation on server side
hi,
i have noticed that the validations in RoR happen at server side
mostly what sites do is using javascript they validate user information
there...
whats the point of doing it at the server side
is it that loading of javascript file in a browser makes a response to
client slow
and validation at server side offsets that....?????
any sugeestions????
is it that i am missing something as
2006 Feb 02
4
Doubts on validation
Hi All,
View
********
<tr>
<td><b>Student: </b></td>
<td><%= text_field "student", "fname", "size" => 40, "maxlength"
=> 40 %></td>
</tr>
<tr>
<td><b>Program: </b></td>
<td><select id="student_program_id"
2006 Jan 27
17
Multiple Model Validation
Hey All !
I have a form which contains two models. I would like both models to be
validated, but have their validations aggregated on the page.
If I do:
<%= error_messages_for(:model1) %>
<%= error_messages_for(:model2) %>
It puts two big validation blocks on the page. I would like all the errors
from both models, but only in one validation box.
Is this possible ? All my attempts
2006 Mar 13
3
validation and update
Hi,
I have validation working in a situation similar to the following.
(Please forgive any minor typos below)
class Department < ActiveRecord::Base
has_many :people
end
class Person < ActiveRecord::Base
belongs_to :department
validates_presence_of :name
end
@department = Department.new(:name=>"bedrock")
@department.people << Person.new(:name=>"fred")
2006 Jul 07
5
Can a route require POST or GET? / REST problem with routing
Hi,
A store front a customer wants to GET /product/5/show. But for the
application this is really GET /cart_item/new/5 or even better
/cart_item/new?cart_item[product_id]=5
When the customer clicks add_to_cart they POST /product/5/show so that
the url doesn''t confuse the user when any validation errors occur. But
for the applicaiton this should be POST
2006 Jan 23
4
an image that is a clickable link?
Hi,
How do I make an image that is a clickable link the rails way? Is
there a view helper for this?
Thanks,
Peter
2006 Aug 16
5
validation on methods that aren''t part of the database.
using the Rails Recipes book, i went through the tutorial on setting up
authentication on a site. the tutorial was great, but it raises a few
questions.
the fields in the database are password_hash, and password_salt. the
tutorial creates another method for password that takes the value it was
given and hashes it and adds the 6 character salt at the end.
what if i want to perform validation
2006 Mar 16
4
calling an actionview method from inside a model
Hi,
I would like my model instance to produce it''s own list of options for
a form select. This is from a product model that has_many variations
def alts_for_select(current_id)
the_map = variations.map{|v| [v.name, v.id]}
options_for_select(the_map, current_id)
end
the model cannot see the options_for_select method
I tried to use
2006 Jan 15
4
model helper location
Hi,
I''m looking at the rails cookbook for uploading files[1]. At the
bottom of the page it says that the sanitize_filename functioin would
probably go in a helper or a library. I wonder where these files would
be or what they would be called. Pehaps there are some conventions I
need to know about?
Thanks,
Peter
[1] http://manuals.rubyonrails.com/read/chapter/78
2006 Apr 26
10
save new model with child model
Hi,
I am having a problem saving a new model that has an associated child
model. If a new ticket is being created and will have one comment to
go with it then I tried this in my action
@ticket = Ticket.new(params[:ticket])
@comment = Comment.new(params[:comment])
@ticket.comments << @comment
if @ticket.save
@notice = "Ticket added. Thanks for
2006 Jun 05
5
Regexp - date validation
Can somebody tell me why the following RegExp doesn''t work for date
validation in Rails... It validates fine in RadRails -- using REgExp
panel. Intended format: (mm/dd/yyyy):
%r{^(0[1-9]|1[012])(-|/)(0[1-9]|[12][0-9]|3[01])(-|/)(19|20)([0-9][0-9])$}
If i try the following, it works in Rails:
%r{(0[1-9]|1[012])(-|/)(0[1-9]|[12][0-9]|3[01])}
When I add the last piece, it
2006 Mar 22
14
currency conversion webservice in a rails app?
Hi,
I''m interested in using a currency conversion web service in my rails
app. Does anyone have a free service that they use and like? I found
this one
http://www.webservicex.net/WS/WSDetails.aspx?CATID=2&WSID=10
I''ve tried to make a simple, plain Ruby script to connect to this and
get a conversion rate without success.
How do I integrate a webservice into my rails app? I
2005 Sep 27
2
No Custom Validation
Hi,
Correct me if I am wrong but there doesn''t seem to be an easy way to add
validation outside the pre-built ones (validates_presence_of,
validates_lenght_of, etc.).
Ideally there should be something like:
Class Person < ActiveRecord::Base
validates :my_method, :on => create, :message => ''was not valid''
def my_method(param)
false unless
2006 Jan 26
8
switching to edge rails
Hi,
I want to start using has_many :through. I think that eventually I''ll
be removing all uses has_and_belongs_to_many from my project.
Here is my situation
I''m using SVN
I want to use edge rails
Reading the wiki about switching to edge rails[1], I can''t figure out
which combination of subsections I must perform.
Do I want edge rails to reside in the vendor
2006 Apr 01
4
problems getting ActionMailer working (on server)
Hi,
I''ve read the Agile Rails book''s chapter on ActionMailer a few times.
Seems pretty straight forward. Unfortunately I can''t get my
application to actually send mail.
I uploaded my application to the web server and tried to get a mail
message sent. Nothing happened. I looked in the log file and it says
Sent mail:
From: service@freedomkilts.com
To:
2006 Apr 26
3
catch all error for incorrect urls etc
Hi,
I am changing a very standard old school website to rails. When I make
the change to rails, all of the old urls will not be valid. If a
person has a bookmark to an old web page I would like them to be
directed to the front page of the new website www.domain.com. How do I
do this? Do I do something in routes.rb?
Thanks,
Peter
2006 Aug 23
5
validation, concurrency, and transactions
Hi,
Something has been bothering me about model validation: how do I know that
the database has not changed in between when I validate my model''s data, and
when it actually gets saved to the database? As a simple example, say I have
a User model like:
class User
validates_uniqueness_of :username
end
When this gets saved to the database, the validation code checks that there is
2006 Feb 09
2
_marker in dragdrop.js
Hi,
I''ve been confused about the purpose of _marker in dragdrop.js for
quite a while. It doesn''t really look like it does anything with
ghosting on or off. I removed the mark method and didn''t discover any
problems. Is all the mark business a relic from some past idea?
Thanks,
Peter
2011 Feb 28
2
form level validation, where to do it.
Form level validation involving enforcing a relation between two or
more form inputs that may not even be in the model:
I am building a form that will query a range of records between two
dates.
The form ask for a starting data and a ending date.
I want to validate that the user selected a starting data before or
equal to the ending date.
It seems that this validation should happen in the