jorgemanrubia/forceps

Support for namespaced models?

Closed this issue · 6 comments

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?

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

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

👍 for namespaced models support

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.

@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.

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