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

Missing overrided version of ActiveRecord::Associations::CollectionAssociation#ids_reader #390

Closed
pustomytnyk opened this issue Mar 2, 2017 · 4 comments

Comments

@pustomytnyk
Copy link
Contributor

When I'm trying to call model.association_ids for association with composite key it fails with <keys array> is not a symbol nor a string at line

activerecord (5.0.1) lib/active_record/associations/collection_association.rb:60:in block in ids_reader

    if loaded?
      load_target.map do |record|
fail => record.send(reflection.association_primary_key)
      end
@pustomytnyk
Copy link
Contributor Author

I don't know what are correct test cases for this feature

@cfis
Copy link
Contributor

cfis commented Mar 3, 2017

Ok - do you have a traceback?

@pustomytnyk
Copy link
Contributor Author

pustomytnyk commented Mar 3, 2017

@cfis, it occurs in https://github.com/thoughtbot/administrate/blob/master/app/views/fields/has_many/_form.html.erb#L26
on line <%= f.select(field.attribute_key, nil, {}, multiple: true) do %>
where f.object is a model having my_association with composite key
and field.attribute_key is :my_association_ids

then traceback is:

activerecord (5.0.1) lib/active_record/associations/collection_association.rb:60:in `block in ids_reader'
activerecord (5.0.1) lib/active_record/associations/collection_association.rb:59:in `map'
activerecord (5.0.1) lib/active_record/associations/collection_association.rb:59:in `ids_reader'
activerecord (5.0.1) lib/active_record/associations/builder/collection_association.rb:56:in `authors_source_ids'
actionview (5.0.1) lib/action_view/helpers/tags/base.rb:28:in `public_send'
actionview (5.0.1) lib/action_view/helpers/tags/base.rb:28:in `value'
actionview (5.0.1) lib/action_view/helpers/tags/select.rb:16:in `block in render'
actionview (5.0.1) lib/action_view/helpers/tags/select.rb:16:in `fetch'
actionview (5.0.1) lib/action_view/helpers/tags/select.rb:16:in `render'
actionview (5.0.1) lib/action_view/helpers/form_options_helper.rb:163:in `select'
actionview (5.0.1) lib/action_view/helpers/form_options_helper.rb:817:in `select'

@cfis
Copy link
Contributor

cfis commented May 21, 2017

Pull request 391 merged.

@cfis cfis closed this as completed May 21, 2017
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