You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The way it used to work was that when I created a new SourceItem in the admin, it would generate a dropdown containing model names like "SheetMusicPiece" and "SourceCollection". Once I chose the model name, it would then generate a dropdown of instances of that model from which I could choose one to associate a new object with
source'http://rubygems.org'ruby'3.0.1'gem'activemerchant','~> 1.99.0'gem'active_shipping'gem'cancan'gem'ckeditor','4.3.0'gem'devise','~> 4.9.2'gem'erubis'gem'exception_notification','~> 4.5'gem'execjs'gem'jquery-rails','~> 4.5.1'gem'jquery-ui-rails','~> 6.0','>= 6.0.1'gem'haml','~> 6.1','>= 6.1.1'gem'kaminari'gem'kt-paperclip','~> 7.1','>= 7.1.1'gem'mysql2'# required by thinking-sphinxgem'nio4r','~> 2.4.0'gem'nokogiri','~> 1.14','>= 1.14.2'gem'paper_trail','~> 14.0'gem'pg','~> 1.4.6'gem'pdf-core','~> 0.9.0'gem'pdf-reader'gem'prawn','~> 2.4'gem'rack-ssl-enforcer'gem'rails','~> 7.0','>= 7.0.4.3'gem'rails_admin','~> 3.0.0'gem'rails_admin_import','~> 3.0.3'gem'responders','~> 3.1'gem'rexml','~> 3.2','>= 3.2.5'gem'rubyzip','~> 1.0'gem'sprockets-rails','~> 3.4','>= 3.4.2'gem'therubyracer'gem'thinking-sphinx','~> 5.5','>= 5.5.1'gem'tilt'gem'ttfunk','~> 1.7.0'gem'unicorn-rails','~> 2.2'gem'unicorn','~> 6.1'# Install iconv gem to prevent errors after Ruby 2.1 upgradegem'iconv','~> 1.0.4'# Gems used only for assets and not required in production environments by default.group:assetsdogem'sass-rails',"~> 5.1.0"gem'coffee-rails',"~> 5.0.0"gem'uglifier','~> 3.0'endgroup:development,:testdogem'byebug','~> 10.0'endgroup:developmentdogem'spring','~> 3.1.1'endgem'rack-utf8_sanitizer'gem"sassc-rails"
I did a bit of digging and found that the potential issue is in rails_admin-3.1.2/lib/rails_admin/config/fields/types/polymorphic_association.rb and how the entire form is being constructed,
specifically when setting associated_model_config:
when running this in the console for my polymorphic association:
irb(main):003:0> Source.reflect_on_association(:resource_item).klass/home/user/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-7.0.4.3/lib/active_record/reflection.rb:423:in `compute_class': Polymorphicassociationsdo not supportcomputingtheclass.(ArgumentError)
so when it comes to constructing the form in rails_admin-3.1.2/app/views/rails_admin/main/_form_polymorphic_association.html.erb
The type_collection variable is nil, which is why there are no dropdown options in the DOM.
So my question is: Is this a bug, or is the functionality I'm expecting no longer supported? Please, advice what should I do in this situation, I’m getting kind of desperate trying to make it work
Thanks!
The text was updated successfully, but these errors were encountered:
Hi! I’m upgrading from rails_admin
0.0.5
to 3.1.2 and I’m having issues with polymorphic select forms/dropdown.It worked great in rails 3, but not in rails 7.
I have these 4 models with polymorphic relations:
The way it used to work was that when I created a new
SourceItem
in the admin, it would generate a dropdown containing model names like "SheetMusicPiece" and "SourceCollection". Once I chose the model name, it would then generate a dropdown of instances of that model from which I could choose one to associate a new object withThis is a rails admin config in initializer:
Expectation (rails 3):
Rails 7:
My Gemfile:
I did a bit of digging and found that the potential issue is in
rails_admin-3.1.2/lib/rails_admin/config/fields/types/polymorphic_association.rb
and how the entire form is being constructed,specifically when setting
associated_model_config
:when running this in the console for my polymorphic association:
so when it comes to constructing the form in
rails_admin-3.1.2/app/views/rails_admin/main/_form_polymorphic_association.html.erb
The
type_collection
variable isnil
, which is why there are no dropdown options in the DOM.So my question is: Is this a bug, or is the functionality I'm expecting no longer supported? Please, advice what should I do in this situation, I’m getting kind of desperate trying to make it work
Thanks!
The text was updated successfully, but these errors were encountered: