similar to: validation only on a specific action

Displaying 20 results from an estimated 10000 matches similar to: "validation only on a specific action"

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
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
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
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/.
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.
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 Jun 19
2
call validate functions
Hi on the code below the validates all the form fields if @client.save flash[:notice] = ''Client was successfully created.'' redirect_to :action => ''list'' else render :action => ''new'' end how can I do this action without having to save the object? ie if validate #move on to next stage else redner
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 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 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 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 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/.
2008 Nov 19
2
Where should I put "prerequisite logic"?
Hi there, I have this model called InventoryItem. Every time an InventoryItem is created (through the CharactersController and the create_item action) I need to update others tables and make lookups in other tables, to check if the Character has the prerequisites to actually create the InventoryItem. My problem is that I cannot seem to find a good place to put this logic. I''ve tried to
2006 Feb 03
6
Go back to previous action
Hello all! I have two views (list_1 and list_2) that show a list of users in two different ways. In the views for these actions there is a link to edit a specific user properties (edit_user). That works fine, except that when I change the user I want to go back to the view that originated the request and not to the default list (list_1). Can anyone help me? Best regards, Hugo -- Posted via
2007 May 23
6
RESTful RESOURCE PARTIAL UPDATE
I have modified scaffolding code slightly to get three edit actions and three update actions. The requirement: to allow users to edit attributes for the same model from seperate forms instead of one form, while using the given scaffolding code and performing model validations. I am using restful_authentication with the login email password validations defined. class users_controller
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
2006 Mar 29
5
How to skip password validation when updating other fields?
Besides the hashed password, which is saved to db, I have two password-attributes in my User model: attr_accessor :password, :password_confirmation I have validations on these attributes, and I need them to work both on create and update, since I have pages for changing and resetting the password. Now when I want to update just the user''s login name, I guess I have the next
2006 Jul 03
2
rjs renders string or partial but not template or action
Hi, I have an rjs file. I only have one controller called called front. I have views called "new_title.rhtml" and "_new_title.rhtml" These work page.replace_html ''title'', ''new title'' page.replace_html ''title'', :partial => ''new_title'' page.replace_html ''title'',
2015 Jul 28
3
Regarding Static website generator [GSOC Docs-toolchain]
Hi, Lei and I have been working on the project, based on community input. We have implemented two way sync between github and pagure as suggest by many. Now we want build the site and display it to user. There are number of options mkdocs, hugo(docker uses it now) etc. There are pros and cons to each site generator. To use hugo, we need the user to have hugo installed too, and than he needs to
2006 Mar 13
3
validates_associated problem
Hello, I have a situation where an ''employee'' belongs to a ''department'' and have setup the relationship as follows. class Employee < ActiveRecord::Base belongs_to :department, :foregin_key => "department_id" validates_associated :department_id end class Department < ActiveRecord::Base has_many :employees def validate_on_update