jorgemanrubia / forceps

Copy active record models from remote databases
MIT License
265 stars 26 forks source link

Support for namespaced models? #2

Closed taboularasa closed 10 years ago

taboularasa commented 10 years ago

Hi there, I'm getting an error when calling Forceps.configure

NameError: uninitialized constant Forceps::Remote::Product_FramePhoto

The class is Product::FramePhoto, do I have something configured incorrectly or does forceps not support namespaced models?

jorgemanrubia commented 10 years ago

To be honest, I haven't tested it with namespaces models referenced from associations. It is probably failing when handling those. I am sure it is easy to add support for them. I'll have a look at this.

Thanks for telling

taboularasa commented 10 years ago

Hey thanks for getting back. Let me know if theres anything I can do to help!

atipugin commented 10 years ago

:+1: for namespaced models support

jorgemanrubia commented 10 years ago

I've been looking at this. It turns out that forceps currently works with namespaced models, but it requires an undocumented workaround.

Right now, if you have a class Product::FramePhoto the remote counterpart will be Forceps::Remote::Product_FramePhoto (the :: is replaced by _). But everything will work as expected (including exploring associated namespaced models).

@taboularasa I think the error you are obtaining is because you need to invoke:

Rails.application.eager_load!

You must invoke that before Forceps.configure. The reasons for that are explained here.

I will leave this issue open as I would like to get rid of that workaround. But for now I will just document it. Please, could you confirm that it works for you.

taboularasa commented 10 years ago

@jorgemanrubia Thanks for your time! I can confirm that Rails.application.eager_load! before Forceps.configure does get me passed the error. I'm still unable to get through a full download of a complex relationship ( now failing with NameError: wrong constant name 0 ) but I expect my new error is unrelated to this thread.

jorgemanrubia commented 10 years ago

This is supported since v0.6.7. Kudos to @cantino