Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resources from isolated engines cannot be saved #3423

Closed
sindrenm opened this issue Sep 11, 2014 · 2 comments
Closed

Resources from isolated engines cannot be saved #3423

sindrenm opened this issue Sep 11, 2014 · 2 comments

Comments

@sindrenm
Copy link

When calling param_key on an ActiveModel::Name that wraps a resource from an isolated engine, it will strip off the namespace for that engine. Because of this, it is important that ActiveAdmin uses the ActiveAdmin::Resource::Name#param_key proxy everywhere it needs the param key.

Now, 8872d84 claims to fix something, but I have to admit that I don't really understand what is being fixed. In any case, it breaks forms using resources from isolated engines.

As an example, say I have an isolated engine called Blog. It has a model called Post. Then, due to the way isolated engines work, this happens:

Blog::Post.model_name.param_key # => "post"

So, according to Rails, this is correct, but the controller for the Blog::Post resource will expect parameters for a resource called blog_post, not post and be unable to create/update the resource.

Note that this is specific to isolated engines. For a resource that has been defined in the main application, everything works fine (because ActiveModel::Naming doesn't remove the namespace on param_key). So if I define a Zoo namespace with a Zebra model in it (in the main app), it works as expected:

Zoo::Zebra.model_name.param_key # => "zoo_zebra"
@timoschilling
Copy link
Member

I'm going to close this, while the sense of a isolated engine is that the models are isolated from the app.

Eventual it will help your to try the usage of inherited_resources#defaults.

@timoschilling
Copy link
Member

@seanlinsley proposed a solution on a similar problem #3161 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants