-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Tables won't always be named after models #1569
Tables won't always be named after models #1569
Conversation
9376645
to
3d59c6b
Compare
3d59c6b
to
b2cb529
Compare
@pablobm I tried to load the branch in my project as follows: # Gemfile
gem 'administrate', git: 'https://github.com/pablobm/administrate.git', branch: 'association-search-table-name' But I get
Any idea what I might be doing wrong? |
That's strange. It looks to me like a GitHub issue. I upgraded from Administrate 0.12 to 0.13 on a dummy app and it installed the SHA that your setup claims to be missing:
That SHA is also present on Github at pablobm@b2cb529 Perhaps try going back to 0.12, bundle, then 0.13 again? Or wiping out the gem from your machine and trying again. For example, in my machine it's at |
@pablobm no luck but as a workaround I cloned your branch and used I encountered one issue: # lib/administrate/search.rb
def association_search?(attribute)
return unless attribute_types[attribute].respond_to?(:deferred_class)
attribute_types[attribute].deferred_class < Administrate::Field::Associative
end EDIT: updated code above which contained an error. EDIT2: this is actually the same problem that happened in base_controller.rb as discussed here, there seems to be an opportunity to DRY up the code. |
@pablobm I updated previous comment, with that change now the search works for me 🎉 |
b2cb529
to
3719ce5
Compare
Uh, I thought I had merged a fix for this some time ago. Turns out I hadn't: #1398 Merged now. That other PR I just merged takes a bit more of a heavy-handed approach. I like your solution using administrate/lib/administrate/base_dashboard.rb Lines 76 to 80 in acada05
As for this PR here, I just rebased it. Would you be able to check that the problem is actually fixed now? |
Thank you @sedubois! |
Alternative to #1264.
Fixes #1179.
Currently,
Administrate::Search::Query
makes the assumption that an association's table name will have the same name as the association attribute, ignoring a:class_name
option that signals otherwise.This change uses the
:class_name
option when given.Changing the example app also provides a way to test this as part of the existing feature specs.