We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
change_assocation
Consider the following model.
class Post < ApplicationRecord belongs_to :user, optional: true end
Now consider a form model which resolves a post's user only to visible users.
user
class Frontend::Post < ActiveType::Record[::Post] change_association :user, -> { visible } end
The above will not work, and instead result in an error:
lib/active_type/change_association.rb:18:in `merge': no implicit conversion of nil into Hash (TypeError)
Instead, passing an (empty) options hash is required to make it work:
class Frontend::Post < ActiveType::Record[::Post] change_association :user, -> { visible }, {} end
I assume the culprit is that the new_options argument defaults to nil instead of {}: https://github.com/makandra/active_type/blob/v2.3.0/lib/active_type/change_association.rb#L9-L18
new_options
nil
{}
The issue is only revealed when passing a scope proc due to https://github.com/makandra/active_type/blob/v2.3.0/lib/active_type/change_association.rb#L11-L14
The text was updated successfully, but these errors were encountered:
Issue #168: Fix change_association with only a scope proc
change_association
18006da
Hello foobear,
your assumption seems right. I made a fix that will be released soon as version 2.3.1.
Sorry, something went wrong.
No branches or pull requests
Consider the following model.
Now consider a form model which resolves a post's
user
only to visible users.The above will not work, and instead result in an error:
Instead, passing an (empty) options hash is required to make it work:
I assume the culprit is that the
new_options
argument defaults tonil
instead of{}
: https://github.com/makandra/active_type/blob/v2.3.0/lib/active_type/change_association.rb#L9-L18The issue is only revealed when passing a scope proc due to https://github.com/makandra/active_type/blob/v2.3.0/lib/active_type/change_association.rb#L11-L14
The text was updated successfully, but these errors were encountered: