similar to: [Rails 2.3] nested_attributes and validation of nested model

Displaying 20 results from an estimated 1300 matches similar to: "[Rails 2.3] nested_attributes and validation of nested model"

2013 Feb 27
0
Exended modules and reject_if in nested_attributes
I have some common class methods in a module ''active_record_additions'' that I load into a class by Activity by using extend ActiveRecordAdditions The Activity class uses nested_attributes_for with a reject_if method saved in the module ''active_record_additions'' The problem is that the class methods in ''active_record_additions'' works when I
2006 Jul 12
0
Give form elements "fieldWithErrors" class in non-std. way?
All, I want to know how to force an element of my model to be invalid, but not generate any message for it, so that the corresponding form field on a form will show up with the ''fieldWithErrors'' class. I have some checkboxes on my RHTML form, and they are generated with this code <%= check_box_tag("current_job[target_list_ids][]"...etc. %> target_list_ids
2009 Jul 01
2
Nested Forms - how to displayed the attributes content ?
I have a User model class User < ActiveRecord::Base has_one :account accepts_nested_attributes_for :account, :allow_destroy => true validates_associated :account attr_accessible :account_attributes is working fine, validating and updating both records (User and Account), but I caanot display the value in the form when is updated, ex: below the firstname is not displayed but
2007 Nov 27
1
O/T div.fieldWithErrors styling
this is kinda trivial but I''m anal and it bugs me :) whenever there''s a error in the form the error field is wrapped with <div class="fieldWithErrors"> </div> this throws my form''s styling off because it puts too much space b/t fields and worse makes the form as wide as possible. How do I fix this? I''ve tried div.fieldWithErrors {
2005 Aug 19
1
css style fieldWithErrors when using tables
I''ve run across something that I''m not sure how to fix. This is with MSIE, Firefox doesn''t seem to have the same problem. When rails displays form fields in error using the css element fieldWithErrors, and the form field is enclosed in a table data tag, the entire background of the table data element is set to red instead of just the border of the form element.
2006 Oct 04
0
Displaying validates_acceptance_of Errors In A Check Box
Hello, I am having trouble displaying a check box which must be checked but hasn''t been. I would like it to be highlighted as in a scaffolded view but the hidden check box field which is generated by the check_box helper is also highlighted, and the text next to it loses its styling. My code follows. Should I get cleverer with the CSS or write my own check_box helper which
2007 Jan 13
1
fieldWithErrors - does not work
What conditions must be met for ''fieldWithErrors'' automatic wrapping? <% remote_form_for( :subscriber, :update => ''subscription'', :url => {:controller => ''subscribers'', :action => ''subscribe''} ) do |form| %> <p> <%= form.text_field
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
2006 Jan 03
6
Am I going too far or Rails is just confusing? was {validates_presence_of *_id attributes}
Thanks for the input Blair Zajac and Chris (Nolan and Hall), and for others. If all of you have time, please follow this (the question still relates to the previous posts by me): I have provided full steps to reproduce the symptoms. If it matters, I''m running Ruby 1.8.2, Rails 1.0, and MySQL 5.0.15 on Windows XP Professional. 1. First, the setup MySQL ----- create database testdb;
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 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.
2006 Apr 09
12
Validating two models from one form
Howdy, I''m working on my first RoR project, and I want to build a form. The tricky thing is, this form needs to insert / update against two models, each with their own validation rules. Unfortunately, I''m having an incredible amount of difficulty with the error handling, specifically the fields wrapped in <div class=''fieldWithErrors''></div>