Re: AssociationTypeMismatch expected Project got Project

Eduardo Yáñez Parareda
Tue, 06 Oct 2009 08:00:13 -0000

Thank you very much for that explanation.


On Oct 5, 1:57 pm, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> On Oct 5, 11:33 am, Eduardo Yáñez Parareda
<eduardo.ya...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> wrote:> Using RAILS_GEM_VERSION = ''2.1.2''
>
> > Hello, I''m developing a plugin for another rails app. When I
try to
> > show the new form view I got this error:
>
> >  ActiveRecord::AssociationTypeMismatch in Audit testsController#new
>
> > Project(#70348727429120) expected, got Project(#70348730882020)
>
> The root cause of your problem is that in development mode  plugins
> are not reloaded between requests (at least that''s the default)
but
> your application classes are, so if your plugin model class holds a
> reference to one of your model classes then from the second request
> that reference now points at an old version of the class (which
isn''t
> equal to the fresh one, hence the slightly confusing message).
> One way around this is to have your plugin be reloaded on each request
> too, among other ways this can be done by removing it from
> ActiveSupport::Dependencies.load_once_paths (which was just
> Dependencies.load_once_paths in a previous version of rails -
don''t
> remember when the switch happened(
>
> Fred