Can someone explain why a instance variable cannot be changed through an association under rspec/factory_girl? An example is in this gist<https://gist.github.com/2484336> . All tests pass except the last. All the steps pass in the console. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/PtSfKHeATc8J. 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.
On Apr 24, 8:48 pm, IAmNan <dger...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Can someone explain why a instance variable cannot be changed through an > association under rspec/factory_girl? An example is in this gist<https://gist.github.com/2484336> > . >When you use .first and if the association is not already loaded then the object is refetched from the db each time, so the unsaved change you''ve made to the object is lost. Fred> All tests pass except the last. All the steps pass in the console.-- 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.
I see. No cache. So it''s effectively a no-op. That explains why update_attributes instead of the = operator works as expected. It seems kind of pointless for a framework to allow such a thing. Boy, I''ve got a lot of old code to revisit. Thanks for your feedback, Fred. On Tuesday, April 24, 2012 4:13:06 PM UTC-10, Frederick Cheung wrote:> > > > On Apr 24, 8:48 pm, IAmNan <dger...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Can someone explain why a instance variable cannot be changed through an > > association under rspec/factory_girl? An example is in this gist< > https://gist.github.com/2484336> > > . > > > > When you use .first and if the association is not already loaded then > the object is refetched from the db each time, so the unsaved change > you''ve made to the object is lost. > > Fred > > > All tests pass except the last. All the steps pass in the console.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/dRziylwYL_QJ. 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.