Consider these two models: class Article < ActiveRecord::Base has_many :posts end class Post < ActiveRecord::Base belongs_to :article end The ActiveRecord::Dirty module allows one to detect changes in a model''s attribute. In the above example, how does one detect if the number of posts an article has changed, or the posts themselves have changed from the point of view of an Article object? In other words, is there something like "article.posts_changed?"? -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Here''s an example for you: http://ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-dirty-objects -- Posted via http://www.ruby-forum.com/. -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I took a look at the referenced article but I don''t see where it addresses a has_many association. What am I missing? Thanks. On Feb 1, 3:30 pm, Alpha Blue <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Here''s an example for you: > > http://ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-dir... > > -- > Posted viahttp://www.ruby-forum.com/.-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Jerry, I had this same problem, but dirty attributes don''t work for associations. I ended making my own plugin for it, called Dirty Associations, and it might be exactly what you''re looking for. You can get it here: http://github.com/daphonz/dirty_associations -Casey On Feb 1, 6:57 pm, Jerry Franks <jerryfranks4...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I took a look at the referenced article but I don''t see where it > addresses a has_many association. What am I missing? Thanks. > > On Feb 1, 3:30 pm, Alpha Blue <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > > > Here''s an example for you: > > >http://ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-dir... > > > -- > > Posted viahttp://www.ruby-forum.com/.-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.