similar to: Custom Validations

Displaying 20 results from an estimated 2000 matches similar to: "Custom Validations"

2006 Mar 16
4
Handling/Catching Exceptions
Hello! I was wondering, sometimes I raise an exception in my Rails apps, e.g.: raise SecurityError unless @post.user == logged_in_user Now: is there any way to catch that SecurityError exception somewhere and render a custom template? E.g., I want to render ''app/views/content/security_error.rhtml'' Does anyone know how to do this? Thanks a bunch, Rob
2006 May 21
3
Sending mail times out (ActionMailer)
Hi! I''m on debian. Sending a mail from Rails times out: Timeout::Error (execution expired): /usr/local/lib/ruby/1.8/timeout.rb:54:in `new'' /usr/local/lib/ruby/1.8/net/protocol.rb:206:in `old_open'' /usr/local/lib/ruby/1.8/timeout.rb:56:in `timeout'' /usr/local/lib/ruby/1.8/timeout.rb:76:in `timeout''
2006 Apr 01
2
Textile headaches
I have the newest version of RedCloth installed (3.0.4). I want the following output: <h1>Header</h1> <p>Some text</p> This is what I tried but no luck: irb(main):002:0> require ''rubygems'' => true irb(main):004:0> require_gem ''RedCloth'' => true irb(main):006:0> RedCloth.new("h1. Header\r\nSome Text").to_html
2006 Aug 09
6
How to change the error message easy way
validates_presence_of :fname results in the error message "Fname can''t be blank". What I want is "First Name can''t be blank". I could do this def validate errors.add_to_base("First Name can''t be blank") if fname.blank? end I find this clunky and I have to put everyrhing in the validate method. Is there an easy to get what I want. I
2006 Apr 14
2
Markaby trunk broken?
Hello! Does anyone know how I can check out the Markaby trunk? I''m getting this error: <code> ruby script/plugin install http://code.whytheluckystiff.net/svn/markaby/trunk + ./trunk/svnindex.xsl /usr/local/lib/ruby/1.8/open-uri.rb:290:in `open_http'': 404 Not Found (OpenURI::HTTPError) from /usr/local/lib/ruby/1.8/open-uri.rb:629:in `buffer_open''
2006 Apr 07
6
validation nightmare
Please help, I am really at a loss at how validation is supposed to work in rails. Model contains acts_as_tree I want to force my NEW objects to have a parent I do NOT want existing object to have a parent so I only want to have parent_id on create, NOT on update. I am trying this: def validate_on_create validates_presence_of :parent_id, :message => "You must specify a
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 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
2006 Jun 06
14
How can I set the session in a functional test?
Hey :) I need to simulate a login in my functional test, otherwise I can''t GET nor POST to the action. I need to set the session key "logged_in_user_id". I tried this inside the setup() method: session[''logged_in_user_id''] = 1 But that throws: TypeError: can''t convert String into Integer Any ideas? Thanks, Rob -------------- next part
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
1
Don''t log params
Hello! I need to supress the logging of params for certain actions, i.e. I don''t want the params hash to show up in one of my actions. Does anyone know how to do that? Thanks, Rob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060716/62b2e2d5/attachment.html
2010 Feb 03
4
customizing validation msg
Hi, i am using the default validation of RoR how i will customize them i dont want to display the default message but i want to print the message i want like for city_id the default message is "City can''t be blank" i want this message as "Please enter city" Regards -- You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2009 Apr 02
3
error_messages_for does not display the error
Hi all I''ve approached Rails since a couple of months to develop a quick application for my company. Fantastic framework. As every noob, I do have some gaps to cover. The one which is giving me a little frustration, generated by my lack of knowledge is as follows. I need to make sure the region object is not deleted if there are countries associated with it. I solved this by putting a
2006 Dec 02
2
Strict STI?
Is there a way to set the base class to abstract? or otherwise enforce that no one can create a "Pet"? Pet < ActiveRecord Dog < Pet Pig < Pet I''ve tried: class Pet < ActiveRecord::Base validates_presence_of :type end but I get an error about ../vendor/rails/activerecord/lib/active_record/validations.rb:74: warning: Object#type is deprecated; use Object#class
2006 Dec 11
2
Custom Validator
I want to add a custom validator in one of Model. For example Rails has inbuilt validation methods like validates_uniqueness_of, validates_presence_of . What I need is a similar kind of method (example: validates_line_items), that can run my custom code while saving, updating the record and can add custom error messages to the record. Please help me by suggesting how i can do this. -- Posted via
2009 Jun 25
4
standard ActiveRecord validation message
in testing my app I just use the validations validates_presence_of :first_name, :last_name, :email validates_presence_of :academy, :message => "You must select an Academy" validates_presence_of :role, :message => "You must select a role" standard error_messages are fine for most of my fields , resulting in : 5 errors prohibited this data from being saved There
2011 Jun 15
1
.new_record? and :_destroy
Rails version 2.3.8 I have a ticket model that has many comments the comments have an attribute called "admin" -- is this a comment added by an administrator the ticket has an attribute called "admin_email_address" I want to validate when saving the ticket and say "if I have a new admin comment, make sure I have an admin_email_address" In my ticket model, the
2006 Mar 13
6
JobsOnRails
Announcing... JobsOnRails! I''m creating on a Ruby on Rails oriented job site and will be launching in the next few weeks. It''s a Rails-centric place for developers and employers to get in touch with a minimum of hassle. For now, I have a short outline of my ideas and an email signup form on the live site at http://www.jobsonrails.com. The site is coming along nicely and
2006 Jan 23
5
validates_uniqueness_of :username, :if => !self.new_record?
Hi all I want users to register on my page. To register, they only have to deliver an email and a password. Then a link with an activation token will be sent to them, and after clicking the link the user sees a page where he should fill in further details, means: a username. My model looks like this: class Member < ActiveRecord::Base validates_presence_of :username, :if =>
2006 Jan 20
3
Is there a way to validate a model w/o saving it?
I have some code in my controller which looks like this: if request.post? and @account.save and @user.save ... end and in my Account and User models I have many :validates, like so account.rb validates_presence_of :subdomain, :on => :create validates_uniqueness_of :subdomain, :on => :create, :message => "is already being used" validates_exclusion_of