search for: before_validation_on_cr

Displaying 9 results from an estimated 9 matches for "before_validation_on_cr".

2006 Dec 11
1
Compute date during before_validation_on_create
Hello, - the form posted by the user have a date field - this date is begin_date, I need to compute end_date - so, added callback before_validation_on_create - in this method I do : end_date = begin_date >> 12 - unfortunately, beeing in before_validation the actual self.begin_date have not been type casted - It''s always a string - unfortunately again, I can''t put this code in before_create because the validation will not pass...
2006 Jul 22
7
Validation with has_many
I have two problems. I have a comment that has_many uploads. Before saving the comment, I want to be sure that the upload(s) has passed validation, but I also need to validate in other ways. For example, I do not want to save the comment if there is no comment or upload. Or, I do not want to save the comment if the image has been uploaded previously (comparing md5s with past upload md5s
2010 May 16
0
update_attributes for nested form
I have two models. model A has_many :b def before_validation_on_create ......... end model B belongs_to :a In b''s controller and ''update'' action, I have a.update_attributes(params[ :a ]) So when I was trying to create a new ''b'', before_validation_on_create is being called twice. Pleas let me know if you guys ha...
2006 Jun 04
5
Manipulating form inputs?
I have created a scaffold Admin/Radicals for doing CRUD. However, I''m not sure exactly where the scaffold uses the save() method. For a new entry, it creates form "radical" referencing method create(). The code for create() is as follows: def create @radical = Radical.new(params[:radical]) if @radical.save flash[:notice] = ''Radical was
2009 Feb 23
2
geokit - using :through to connect models
...models together using geokit. for some reason, i am running into a problem: ArgumentError: Unknown key(s): as i have two models, one that is geocoded, and one that belongs to that model. the models look like: ,----[ employer.rb ] | class Employer < ActiveRecord::Base | acts_as_mappable | before_validation_on_create :geocode_address | | has_many :internships | belongs_to :account | belongs_to :role | | private | def geocode_address | geo=GeoKit::Geocoders::MultiGeocoder.geocode(address1 + " " + city + " " + state + " " + zip) | errors.add(:address, "Cou...
2008 Nov 10
1
is there a "validates_empty" method or a way to do this in a single line?
Hi, re Model validations: is there a "validates_empty" method or a way to do this in a single line? tks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from
2006 May 24
1
Observer behavior differences between DEV and TEST environments ?
...s don''t work... So, I took a step back and put in the following code: class GreenbackTransactionObserver < ActiveRecord::Observer %w( after_find after_initialize before_save after_save before_create after_create before_update after_update before_validation after_validation before_validation_on_create after_validation_on_create before_validation_on_update after_validation_on_update before_destroy after_destroy ).each do |method| define_method(method) do |txn| txn.logger.info "#{method} (observer)" true end end end My model looks like this: class Gree...
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
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