Snow Hellsing
2013-Jan-10 08:03 UTC
[ActiveRecord] How to avoid touching a class more than once in a reference hierarchy
say there are AR classes (omitted ` < ActiveRecord::Base`): ```ruby class Project end class Member belongs_to :project, touch:true end class Todolist belongs_to :project, touch: true end class Todo belongs_to :todolist, touch: true belongs_to :member, touch: true end ``` When I save a Todo instance, referenced Project instance will be touched twice. Is there any way to avoid this? Appreciate for help. And sorry if my English is broken. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/WZkohL8NSMIJ. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Jan-10 13:29 UTC
Re: [ActiveRecord] How to avoid touching a class more than once in a reference hierarchy
On 10 January 2013 08:03, Snow Hellsing <snow.hellsing-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> say there are AR classes (omitted ` < ActiveRecord::Base`): > ```ruby > class Project > end > > class Member > belongs_to :project, touch:true > end > > class Todolist > belongs_to :project, touch: true > end > > class Todo > belongs_to :todolist, touch: true > belongs_to :member, touch: true > end > ``` > > When I save a Todo instance, referenced Project instance will be touched > twice. > Is there any way to avoid this?First a question, will the todolist and member that a todo belongs to always belong to the same project? So rather than being one project touched twice it may be two separate projects? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.