-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Polymorphic associations don't work with namespaced classes #3376
Comments
jacob-carlborg-apoex
added a commit
to jacob-carlborg-apoex/rails_admin
that referenced
this issue
Aug 11, 2021
…espaced classes
jacob-carlborg-apoex
added a commit
to jacob-carlborg-apoex/rails_admin
that referenced
this issue
Aug 11, 2021
…espaced classes
jacob-carlborg-apoex
added a commit
to jacob-carlborg-apoex/rails_admin
that referenced
this issue
Aug 12, 2021
…espaced classes
jacob-carlborg-apoex
added a commit
to jacob-carlborg-apoex/rails_admin
that referenced
this issue
Aug 17, 2021
…espaced classes
mshibuya
added a commit
that referenced
this issue
Aug 18, 2021
…olymorphic-association-3376 Fix #3376: Polymorphic associations don't work with namespaced classes
This was referenced Oct 13, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given a set of models:
When creating a new
Picture
, in the form, after selecting the type, RailsAdmin will fail to load the records for the associations. The problem is that RailsAdmin will get the name of the model:https://github.com/sferik/rails_admin/blob/238f18ee2386f9858670b7995dcb628b8fe6bde9/lib/rails_admin/config/fields/types/polymorphic_association.rb#L66
Which is then used as the
id
of an HTML tag:https://github.com/sferik/rails_admin/blob/238f18ee2386f9858670b7995dcb628b8fe6bde9/app/views/rails_admin/main/_form_polymorphic_association.html.haml#L2
https://github.com/sferik/rails_admin/blob/238f18ee2386f9858670b7995dcb628b8fe6bde9/app/views/rails_admin/main/_form_polymorphic_association.html.haml#L12-L15
https://github.com/sferik/rails_admin/blob/238f18ee2386f9858670b7995dcb628b8fe6bde9/app/views/rails_admin/main/_form_polymorphic_association.html.haml#L23-L24
When calling
.name
on a model declared in a module, the result will contain colons, i.e.Bar::Product
. A string containing:
is not a valid to fetch an HTML tag using theid
attribute, as the JavaScript does here:https://github.com/sferik/rails_admin/blob/238f18ee2386f9858670b7995dcb628b8fe6bde9/app/assets/javascripts/rails_admin/ra.widgets.js#L205-L206
I'm using:
rails_admin: 2.2.1
rails: 6.1.4
ruby: 3.0.0
The text was updated successfully, but these errors were encountered: