similar to: call validate functions

Displaying 20 results from an estimated 30000 matches similar to: "call validate functions"

2011 Apr 28
3
difference between validate and validate_on_create
i just ran into a problem with some test, and i am not exactly sure why, but the difference happened when i changed my model validation from: validate :custom_validation to: validate_on_create :custom_validation can someone give me any ideas on where in the chain the validation takes place? thanks! -- Posted via http://www.ruby-forum.com/.
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 Feb 03
2
validation only on a specific action
Hello again! I have a action that lists users and that allows an admin user to create new users. When the admin user creates a new user an e-mail is sent to the created user telling him to register in the site. I want to validate the user name and password only when the user register and not when the admin user creates it. Can anyone tell me how to do this? Thanks. Best regards, Hugo --
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 Dec 07
2
validate_on_destroy ?
What''s the best way to validate_on_destroy. Rails only seems to include validate_on_create and validate_on_update methods. I don''t want to resort to doing: before_destroy do |j| raise "There is an error" if j.etc end Is there a way of finding out what action (create/update/destroy) is being performed if I use the ''validate'' method? -- Posted via
2006 Feb 28
1
Validate two fields so they do not match
Hey all, I have two form fields (select dropdowns) that are ''startlocation'' and ''endlocation''. These two cannot be equal to each other on save and I am wondering how to put validation into the model for this. Is is possible to do it in the model, or do I need to do this in the controller? Thanks in advance! Ryan -- Ryan Prins rprins@gmail.com
2006 Jan 19
2
Easy way to handle form input without a model class?
I have a couple forms that I''d like to be able to validate and automatically populate, but it shouldn''t be based on AR. In fact I often have a bunch of small forms that I can''t really justify writing a whole new model class for anyway. I''d like to validate the form input, and then use rails helpers to automatically populate the form if validations fail.
2005 Apr 23
7
Validation question
Hi all, Is there a way to invoke validations at times other than save, create and update? I know that I can do this by writing my own validation checks using errors.add_[blah], but I''d like to leverage the existing validation code. What I have is two sets of fields in a record, set A and set B. Both sets must be validated on record create. However, the trouble is that after
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
2006 Mar 02
3
validates_uniqeness_of
Hello, I am trying to understand usage of validates_uniqeness_of. Say I have, two column ''name'' and ''email'' in my table users three unique key is possible for these two columns 1. name 2. email 3. name and email together My question is, if I write validates_uniqueness_of :name, :email what uniqueness is it going to apply, 1 and 2 or, 3 ? Thanks, Mohammad
2006 Feb 17
1
validate() with has_many association
I''m creating a simple portfolio site for a painter. I have a painting and an image model with following relationship: Painting has_many :images Image belongs_to :painting On the edit screen the user can edit the Painting data as well as upload pictures for a thumbnails and full size image. The Image model extracts filename, width, and height from the uploaded file, saves those
2006 Jul 05
2
Serialized object behaves weird
Hi! I got a class named EinsatzFilter which I serialized to session. Before saving to session it works afterwards I keep getting the message: "undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from ActiveRecord::Base inherited class. Code: class EinsatzFilter include ApplicationHelper attr_reader :personen, :monat, :projekte, :kunde
2009 Dec 30
4
Validating the presence of two associated objects from both models
I have a model “Conversation” and a model “Leader”. A Conversation is always led by exactly 1 Leader. I’ve overridden Conversation’s “validate” method to validate the presence of an associated Leader model. If I add a similar validation to the Leader model, however, Conversations can no longer be saved on creation because the Leader model is invalid. On creation of both a new Conversation and
2006 May 04
2
validates :on 2
Hello, I need to have this for :create and :login how do I do so validates_presence_of :login, :password, :password_confirmation, :user_name, :email, :on => :create I do need it to be off in a number of places though -- Posted via http://www.ruby-forum.com/.
2007 Feb 12
8
How to validate puppet manifests without actually executing puppet?
Hi, I want to validate my puppet manifests before I check them into source control. I just want to make sure that the manifest syntaxes are legal, not to do any more complex testing - the checkin may be on my laptop and not on the system that the manifests may be intended to run on. Ideally I''d be able to do this from ruby code - and I did try to instantiate some classes and override
2006 Oct 07
3
blog_id magic with typo
Hi All, I am modifying typo so as, I can host multiple blogs on the same typo. And its almost done, except that...i am stuck at one place. When a user posts a new article, depending upon current blog_id, I would like to set the blog_id attribute of @article object. So..in the admin/content_controller.rb: We have: def new_or_edit if request.post? set_article_author
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
2006 Mar 16
2
question about ajax/rjs and redirection
i don''t even know if this is possible, so I''ll just ask. say I have a remote form. the form data gets submitted to the backend via AJAX. if there is a validation error in the form, i handle that on the AJAX side. however, if the form validates, I''d like to redirect the browser to a different page. Will a redirect_to work with an AJAX call or do I have to handle that
2006 Jun 19
3
Using a records "id" in validation
I need to use an order''s id value in a validation. Basically, I am charging an order via a credit card API. I only want ot save the order if the credit card authorization was approved. I also want to send the order id to the credit card API as a transaction reference. And last but not least I want to add an error to the order object if the transaction is declined. The problem is
2006 Mar 16
2
Verifying existance of related record
Is there an easy way to validate that a related record exists? I''ve got a table that contains a set of categories and I want to make sure the user has entered a vaild category (i.e. a category that exists in the categories table). So in the model of the table I put this: class Master < ActiveRecord::Base belongs_to :category, :foreign_key => "categoryid"