On Mon, Feb 26, 2007 at 04:15:45PM +0100, Peter Bex wrote:
> Hi there,
> 
> We're having some problems with some code in our Engine:
> 
> This code, in our _application's_ (not the engine's) user_controller
> goes wrong:
>       current_company = current_user.employees[0].company
> it raises an exception that the method 'company' does not exist for
> the instance of Employee current_user.employees[0].
> 
> Employee is defined in the application itself, and User is defined in
> the engine.  Employee belongs_to :company and Company has_many :employees.
> 
> This works fine:
>       current_company = Company.find(current_user.employees[0].company_id)

It gets weirder.  I can ask Dependencies if the Employee class is loaded
with Dependencies.send(:qualified_const_defined?, "Employee") and it says it
isn't.  If I then ask for current_user.employees[0].class.id and for
Employee.id, then it returns different values!

It looks like the Rails unloading mechanism doesn't handle dependencies
right in combination with different load paths or with engines, somehow.
I'll continue my investigations.  This might be related to the 
'lib folders and application controllers' thread on engines-users.

Regards,
Peter Bex
Solide ICT - http://www.solide-ict.nl
_______________________________________________
engine-developers mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org

Reply via email to