Displaying 20 results from an estimated 3000 matches similar to: "inverse_of breaks for unsaved child associations during save of parent"
2011 Apr 07
0
accepts_nested_attributes_for, validations, :inverse_of option on associations, and IdentityMap
This feels more like a question to ask the core list, forgive me if I trespass.
I''ve been trying to help one of my cow orkers get through a sticky
problem. He''s got a fairly complex nested form to update a model and
its children. He''s started adding some validations, and we''ve
encountered a number of issues:
First he had a validation on one of the child
2008 Apr 23
1
Validation dependent on unsaved parent
I''m having trouble with a validation that depends on an attribute of a
belongs_to parent. If the child is added to an unsaved parent
(parent.children << new child), the has_many collection
parent.children includes the unsaved child. However the belongs_to
attribute child.parent appears to be nil until the parent has been
saved. Without access to the parent attributes, the validation
2011 Mar 29
0
inverse_of not supported in Rails 3 for has_many?
I was looking through the association classes in the rails 3 source and
noticed that we aren''t supporting bi-directional associations with
has_many and belongs_to:
# NOTE - for now, we''re only supporting inverse setting from
belongs_to back onto
# has_one associations.
def we_can_set_the_inverse_on_this?(record)
@reflection.has_inverse?
2013 Mar 30
1
How to use group in nested associations
The below query fails:
Timesheet.joins(:time_entries).select("timesheets.*,
sum(time_entries.worktime) as total").group("timesheets.start_date")
The models have the following relations:
Timesheet < AR
has_many :activities, dependent: :destroy, inverse_of: :timesheet
has_many :time_entries, through: :activities
accepts_nested_attributes_for :activities,
2006 May 26
0
how to prevent child.save() when doing parent.save() in associations?
When using has_one or has_many associations, how do I prevent a call
to the parent''s save() method from calling the child''s save() method?
I seem to be stuck in an infinite loop due to the way I have my
associations setup :-(
thanks,
Tim
2006 Feb 14
8
Assigning has_many child in parent creation question
If I have...
class Parent
has_many :children
end
class Child
belongs_to :parent
end
...then...
* Assigning a _new_ child during parent''s creation saves the child
record with the parent''s id.
child = Child.new
Parent.create(:children => [child])
# Results in child being associated with parent
* Assigning an existing child after a parent''s creation
2006 Mar 14
2
Two unsaved related objects
Given the two tables Parent, Child where Parent has_many children:
If I don''t save parent first then it seems that child.parent will not
be assigned automatically if I call parent.children << child . Must
the parent record be saved before I call parent.children << child ?
If I must save Parent first then can someone explain to me how I can
call parent.valid? before it
2006 Apr 15
0
parent.children not updated (has_many)
Hi guys!
class Parent < ActiveRecord::Base
has_many :children
end
class Child < ActiveRecord::Base
belongs_to :parent
end
I do:
parent = Parent.find(1, :include => :children)
parent.children.find(3).update_attribute(''name'', ''Tom'') (or
parent.children.find(3).name = ''Tom'')
parent.children.find(3).name
=> ''old
2011 Jan 11
0
Should set_inverse_instance be called earlier in add_record_to_target_with_callbacks ?
Right now when you add a record to an association with << it first
saves the model, and THEN sets the inverse_of association afterward.
This is done inside add_record_to_target_with_callback inside
association_collection.rb.
Is there any reason set_inverse_instance isn''t called before the save
of the model? We are referencing the parent in our save callbacks, so
we''re
2013 Feb 14
0
IWSM 2013: LAST call for papers
dear all,
apologizes for this OT
===========================
28th International Workshop on Statistical Modelling (IWSM), Palermo
(Italy) 8-12 July 2013. http://iwsm2013.unipa.it
Dear friend,
For your information, I would like to bring to your attention that
deadline for submission of abstracts is
FEBRUARY 18
If you are still interested to visit Palermo (and taste its specialities
:-))
2006 Aug 17
1
How to sort child table on fields in the associated parent
For an Xray file system patients have folders and folders have studies.
That is:
patients folders studies
id id id
name patient_id folder_id
... label type
... ...
The list of studies with their associated folder and patient might look
like this:
name folder_label study_type
2008 Apr 28
1
OSX R GUI visual interface tweak (PR#11318)
Full_Name: Ana Nelson
Version: R 2.7.0 GUI 1.24 (5102)
OS: OSX 10.5.2
Submission from: (NULL) (213.94.201.89)
The R GUI close button has a solid circle. Screenshot is here:
http://skitch.com/ananelson/kmxj/r-console
On OSX this indicates that there are unsaved changes pending. Please see page
201 of the Apple Human Interface Guidelines (version 2008-03-11):
2013 Jan 18
0
OT: IWSM 2013
dear all,
apologizes for this off topic.
I would like to inform you that registration and paper submission for
the 28th International Workshop on Statistical Modelling (IWSM)
to be held in Palermo (Italy) 8-12 July 2013 is now open at
http://iwsm2013.unipa.it
Register at http://iwsm2013.unipa.it/?cmd=registration and then submit
your abstract. Deadlines for Abstract submission is February 4,
2006 Mar 13
2
relationship woes
I have two tables:
class PgmUpdate < ActiveRecord::Base
has_many :pgm_visits, :foreign_key => ''pgm_update_fk''
...
and
class PgmVisit < ActiveRecord::Base
belongs_to :pgm_update, :foreign_key =>
''pgm_update_fk'', :dependent => true
...
According to the has_many docs (http://api.rubyonrails.org/classes/
2009 Feb 19
3
Associated child records not created on creation of a parent.
I am trying to create a record with association. Within the create
method, I would also like to pre-populate dependent (has_many) records
from a template in the database.
The child records are <u>mysteriously rolled back </u> if I insert
them in a loop. If I try to insert a single child record, it works.I
have read the books and tried to google my way out of this but am at a
dead
2006 Jun 03
1
Can I tell if the associated record is new in a belongs_to save?
In a belongs_to association, is there a way to tell if the associated object
was newly created?
Hopefully this will explain my question:
A Firm class declares
has_many<http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html#M000530>:clients
and a
client class declares
2009 Nov 02
3
partial matching with grep()
dear all,
This is a probably a silly question.
If I type
> grep("x",c("a.x" ,"b.x","a.xx"),value=TRUE)
[1] "a.x" "b.x" "a.xx"
Instead, I would like to obtain only
"a.x" "b.x"
How is it possible to get this result with grep()?
many thanks for your attention,
best,
vito
--
2004 May 11
2
bilinear and non linear
Dear all,
there are R packages able to simulate or estimate bilinear model for time
series?
I know it is an open problem, but do exist something for very simplified
bilinear models?
Alternatively, what kinfd of non linear time series models are performed
in R?
If R is not able, could someone suggest me for some commercial softwares
to deal with bilinear models?
i'm afraid of a negative
2004 Dec 14
1
correlation in lme4
Dear all,
I have tried to consider a correlation structure in lme (package lme4), but
without success.
I have used something like:
> risul<-lme(y~x+ z , data=mydata, random=~ x | g, correlation = corAR1())
but the result is the same as:
> risul<-lme(y~x+ z , data=mydata, random=~ x | g).
Can anybody help me?
Antonella
**************************************************
Prof.
2007 Dec 06
1
differences in using source() or console
Dear all,
Is there *any* reason explaining what I describe below?
I have the following line
myfun(x)
If I type them directly in R (or copy/past), it works..
However if I type in R 2.6.1
> source("code.R") ##code.R includes the above line
Error in inherits(x, "data.frame") : object "d" not found
namely myfun() does not work correctly.
In particular the