similar to: validated_associated -- how do I assign invalid collection?

Displaying 20 results from an estimated 4000 matches similar to: "validated_associated -- how do I assign invalid collection?"

2006 Jun 12
0
validates_associated -- explicitly setting collection?
Hi, I have a class (say Parent) that has many of two other classes, say FirstChild and SecondChild. These could look like this: class Parent < ActiveRecord::Base has_many :first_children, :dependent => true has_many :first_children, :dependent => true validates_associated :first_children validates_associated :second_children end class FirstChild < ActiveRecord::Base
2005 May 17
3
validates_associated / error_messages_for
When a validates_asssociated fails... I get something like Address is invalid is there a way, preferably on a per-association basis to have the error messaage include the actual error like Zipcode is too long (max is 10 characters) _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
2006 Jan 11
0
Easy Question, I Think
I am just getting started with Rails, don''t know any Ruby, and don''t quite even get object oriented programming yet. I have tweaked my schema to The Rails Way and have generated a bit of scaffolding. I am trying to create a new Part, which references a PartName and a PartNumber. I can create a PartNumber on the fly, but the PartName has to exist. I have an inelegant solution
2006 Jan 12
0
Easy Question, I Think [re-post, sorry if dupe]
I am just getting started with Rails, don''t know any Ruby, and don''t quite even get object oriented programming yet. I have tweaked my schema to The Rails Way and have generated a bit of scaffolding. I am trying to create a new Part, which references a PartName and a PartNumber. I can create a PartNumber on the fly, but the PartName has to exist. I have an inelegant solution
2006 Aug 17
2
validates_associated bug?
i seem to be experiencing a bug where rails tells me that my organization object''s associated credit card is invalid (activerecord validation-wise invalid), when i know it to be valid. this happens only if i tell the organization to validate_associated :credit_card. i know the associated credit card is valid, because a) that credit_card object itself throws no validation errors, and b)
2006 May 11
1
RoR completely ignoring a column when saving changes
I have an action that needs to update two models/two tables in one shot, and it works great, but ignores one column. Here is the action code: (verify_id is irrelevant in this case) [CODE] def edit @page_title = "Edit User" @page_active_3 = "active" if request.post? @user = User.find(params[:id]) @profile = @user.profile verify_id(@user.id,
2006 Mar 14
15
in_place_editor_field -- values not clickable
Hallo -- I''ve just installed the latest stable version of rails, and am following the rails recipies book''s first recipie -- using in_place_editor_field. My problem is that the code throws no error, but the resulting fields are not editable -- the values just come up as text, rather than clickable-then-editable fields. Can anyone help shed any light on why this might be the
2008 Aug 31
9
assigning collection values and exceptions
hi everyone, I''ve this code in my Report model: has_many :report_reasons, :validate => true has_many :reasons, :through => :report_reasons #, :uniq => true # :accessible => true def reason_attributes=(reason_attributes) reasons.clear reason_attributes.uniq.each do |reason| reasons << Reason.find_or_create_by_content(reason) end end
2005 Nov 15
0
validates_associated
I have an db table that associates two things from the same table. people_alt_people ----------------- person_id alt_person_id So my ActiveRecord looks like: class PeopleAltPerson < ActiveRecord::Base belongs_to :person belongs_to :altperson, :class_name => ''Person'', :foreign_key => ''alt_person_id'' validates_presence_of :person
2007 Feb 25
0
validates_associated causing weird results
I''d almost think the presence of "validates_associated" is causing the associated model to run validation twice. The associated model, Upload, which handles uploaded files and saves them, is saving each uploaded file twice in a row. This doesn''t happen if I remove "validates_associated" from the model it belongs to, or if I have the model save files during
2008 Jun 29
2
How to write test about validates_associated
Here is my model: class Account < ActiveRecord::Base has_many :users, :dependent => :destroy has_many :bus belongs_to :currency has_many :mylogs, :dependent => :destroy has_many :batchuserdefines, :dependent => :destroy has_many :materialuserdefines, :dependent => :destroy has_many :materials has_many :inventories has_many :batchs has_many :courses has_many
2008 Jun 10
2
validates_associated doesn't work on update (and i've tried :on => :update)
HI all- I have two models, Story and Tag, and they are habtm. My goal is to show the errors for @story in a form on both new and edit. Everything works fine on new/create, but it fails on edit/update. First the models: class Story < ActiveRecord::Base attr_accessor :tag_string_holder #holds a CSV of tags ... has_and_belongs_to_many :tags, :uniq=> true ... def
2006 Jun 13
6
Dead horse: validates_associated
Regarding validates_associated... Let''s say I have: article belongs_to author But for whatever reason, I want an article to also be written anonymously and therefore not require an author. Then I have: Article: belongs_to :author validates_associated :author But I DON''T have validates_presence_of. What I want to do is validate that an author is valid --if it is
2006 Apr 20
3
Need help cutting down on db traffic
I''m having performance issues with one of my actions, and think I''ve narrowed it down to too many sql queries. I have a form with ~60 lines, which takes ~6 sec to save, 60%+ of that is db io. There''s 650+ lines of log data, most of which are AR/queries. The app is a simple dual entry book keeping thingy, and the form in question contains a journal entry along with a
2006 Mar 24
3
JS validation on a form/submit tag? Like :condition=>...
Hallo -- is there a way anyone know of that I can add a :confirm clause to a form submit? Something like: <%= submit_tag ''commit'', :confirm=>"are you certain?" %> Does anyone know how to achieve this? Cheers, doug. -- Posted via http://www.ruby-forum.com/.
2006 Mar 18
1
has_many and validates_associated
By trial and error I seem to arrive to the conclusion that 1. Validation recurses through has_many by default and a root save! call raises an excepcion if some child no matter how nested is fails validation 2. Validation does not recurse through has_one by default and you can change this with validates_associated, in which case exceptions behave like above
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
2008 Mar 11
1
add_multiple_associated_save_callbacks and validates_associated conflict?
Perhaps I''m misunderstanding what''s happening here, but I''m having a problem with not being able to disable the validation of an associated collection if that collection contains a new record. Example... class Person < ActiveRecord::Base has_many :email_addresses validates_associated :email_addresses, :if => Proc.new { false } end p = Person.new
2006 Aug 19
1
Re: validates_associated
On 8/19/06, Alastair Moore <alastair-mb+lb5rSoAr10XsdtD+oqA@public.gmane.org> wrote: > > Hello all, > > Having a bit of a problem with validates_associated. I assume I''m missing > something out but basically got these two models - > > class Seller < User > > has_one :profile, :foreign_key => ''user_id'', :dependent => :destroy
2007 Mar 30
0
Rolling up validates_associated error messages into parent
All, I really dig using validates_associated on my models to automatically validate their associated objects. However, I find that I would prefer that the associated object''s error messages were propagated up to the original (object on which validate was called) object as they are, instead of the original object showing "X is invalid" where X is one of the associated objects.