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
When we try to load the page for the model we get an error undefined method 'to_sym' for an instance of Array
#<ActionView::Template::Error: undefined method 'to_sym' for an instance of Array>
/path/to/ruby/version/lib/ruby/gems/3.4.0/gems/activeadmin-3.3.0/lib/active_admin/resource/attributes.rb:24:in 'block in ActiveAdmin::Resource::Attributes#foreign_methods'
Having a way to reproduce your issue will help people confirm, investigate,
and ultimately fix your issue. You can do this by providing an executable test
case. To make this process easier, please use [our bug report template script].
Copy the content of the appropriate template into an .rb file and make the
necessary changes to demonstrate the issue. You can execute it by running ruby the_file.rb in your terminal. If all goes well, you should see your test
case failing.
This discussion was converted from issue #8716 on May 27, 2025 20:55.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
We have a model that belongs to another model which has a composite key, e.g. (fictitious key)
[place_id, event_hour, event_min]
belongs_to :place, class_name: "Place", foreign_key: Place.primary_key, optional: true
Expected behavior
The page should load
Actual behavior
When we try to load the page for the model we get an error
undefined method 'to_sym' for an instance of Array
https://github.com/activeadmin/activeadmin/blob/master/lib/active_admin/resource/attributes.rb#L24
r.foreign_key.to_sym
chokes on the foreign key[place_id, event_hour, event_min]
Suggestions:
If that is a column to view / show, then allow it to handle arrays:
Or reject any non-standard keys so we don't show those columns / links?
### How to reproduceHaving a way to reproduce your issue will help people confirm, investigate,and ultimately fix your issue. You can do this by providing an executable test
case. To make this process easier, please use [our bug report template script].
Copy the content of the appropriate template into an
.rb
file and make thenecessary changes to demonstrate the issue. You can execute it by running
ruby the_file.rb
in your terminal. If all goes well, you should see your testcase failing.
[our bug report template script]: https://github.com/activeadmin/activeadmin/blob/master/tasks/bug_report_template.rbSorry, I haven't had time to reproduce. If needed, I will try to do that, but hopefully the issue is apparent above.
Beta Was this translation helpful? Give feedback.
All reactions