Displaying 20 results from an estimated 6000 matches similar to: "Validate a model with a session parameter"
2009 Apr 20
3
xxx.valid? still true after xxx.errors.add(...)?
Hi all
I have the following code in my controller:
if @comment.valid?
captcha_url =
"http://captchator.com/captcha/check_answer/#{captcha_code}/#{@comment.captcha}"
result = open(captcha_url)
unless result.read == "1"
@comment.errors.add(:captcha, "Captcha wurde nicht korrekt
eingegeben")
raise "#{@comment.valid?}"
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 Jul 18
2
validate method doesn''t recognize another instance method
All,
I am attempting to do some custom validation on my object.
Here is my validate method:
protected
def validate
puts "Do I have the target_list_ids method? " +
self.methods.include?(''target_list_ids'').to_s
if target_list_ids.nil? || target_list_ids.length == 0
errors.add_to_base("You must choose at least one target list for
this job")
2006 Jan 19
1
Model Validation & Floating Attributes
Hello all !
I have a model being validated that spits it''s error messages on the
resulting page using:
error_messages_for(:mymodel) .... Basic stuff. It''s working perfectly.
Now, I have something else I want to check on the same page (that isn''t an
attribute to the Model)... and am trying to add it using:
@mymodel.errors.add_to_base("another error here")
2006 Aug 16
3
Validate your forms with a table-less model
Ive followed this example of how to validate a form with a tableless
model:
http://rails.techno-weenie.net/tip/2005/11/19/validate_your_forms_with_a_table_less_model
Ive got this example working but when validation fails the failed boxes
are not highlighted in red. At the moment i have a contact details form
and want to validate the information entered by the user but this will
just result
2009 Dec 21
0
errors.add_to_base translation missing: en, activerecord
In my model I am using errors.add_to_base:
errors.add_to_base "Error 1"
This works fine.
If I do this twice:
errors.add_to_base "Error 1"
errors.add_to_base "Error 2"
I receive the message:
translation missing: en, activerecord, errors, models, modelname,
attributes, base,
as part of my error messages.
Anyone know how to get rid of this?
Many thanks,
Mike
2006 Apr 07
2
errors.add_to_base
What are the limitations on using:
errors.add_to_base
to display errors in views?
I have tried for days to add errors from my object.rb and they never get
displayed.
class Keyword < ActiveRecord::Base
validates_presence_of(:name, :message => "Name is required.")
validates_uniqueness_of(:name, :message => "This name is already in
use. Please try
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
2006 Aug 14
2
after_create is not being called
Hi all
I have the following model:
class PhotoGallery < ActiveRecord::Base
attr_accessible :title, :description, :file_path, :title_photo_id
has_many :photos, :dependent => :destroy
belongs_to :title_photo,
:class_name => ''Photo'',
:foreign_key => ''title_photo_id''
validates_presence_of :title, :description, :file_path
2000 Dec 25
2
Modification requests / question
Hello!
1.
You should modify the 'vorbis_ftoi(f)' for the undefinied OS/compiler
in the 'os.h' on this way:
old:
static int vorbis_ftoi(double f){
return (int)(f+.5);
}
new:
#define vorbis_ftoi(f) ((int)(f+.5f))
Because in some cases we don't use this function, and the compiler writes
many error messages.
2. Could you write a frequency and bitrate independent
2010 Sep 10
2
Simple_captcha issue
I have a weird issue .I am using simple captcha in forms in my rails
applications. If I am using one captcha in a web page I don''t have any
problem. But I have a scenario of using three(3) forms in one page in
which all the three forms will have the captcha . So that when I
refresh the page the captcha data of the three forms are equal.
When we come to database
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 12
1
validate method not getting called?
Here''s a snippet of my model:
validates_presence_of :from_name, :from_email, :reply_name,
:reply_email, :eSubject
protected
def validate
puts "Calling: #{target_list_ids}"
errors.add_to_base("You must choose at least one target list for
this job") if self.target_list_ids.nil?
end
It appears that the validates_presence_of are being called just fine,
2006 Jul 16
0
Captcha Fun
Hello,
I am trying to integrate a captcha into a form that is used to update a
database. I am using a method that is outlined here:
http://svn.2750flesk.com/validates_captcha/trunk/README, but things are not
working correctly. The captcha image shows up in the user form, but the
captcha input is being ignored. The following shows my controller file:
class PublicController <
2004 Oct 28
1
Converting an LDAP server to use Samba 3
I know this might not be the best place for this, but I'm hoping someone
else has done this or knows what I need to do.
We have a Linux LDAP Server (OpenLDAP 2.0.27) serving unix accounts to
Linux and OS X machines. To get it to serve to OS X machines, I copied
over the 'apple.schema' from an OS X box. Itr seems this schema file
depends on things defined in the Samba 2.x schema
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
2010 Apr 29
1
Setting a message on a model -without- errors.add_to_base
I''m trying my best to follow the skinny controller/fat model concept,
and I''ve got a series of callbacks (that I''m about to move into
observers) running on a few models. Based on what these callbacks do
to the data (it''s implementing business rules), I''d like to add some
type of message on the state of the model *without* invalidating it.
For example:
2011 Sep 09
9
Captcha conception
Hi guys, the next problem:
I create a controller, (/controllers/rmagick_controller.rb), which have
aim to test an captcha
Actions:
def download # creates an captcha image
def show # show the page where image took place
def check # must check right captcha or wrong
views/rmagick/show.html.erb:
> <div id="captcha">
> <p><%= image_tag download_rmagick_path
2007 Sep 02
0
using database for validation
I''ve been playing around with the idea of using the database for model
validation where possible (instead of duplicating that validation in
rails). My first approach to this was to catch exceptions from save/
create and parse the errors, in my case from postgres, to turn them
into something friendlier. Something like:
def update
create
end
def create
begin
super
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,