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
I'll be upgrading to rails 6 eventually (where this issue doesn't exist), but in the meantime, is overriding this one line appropriate? Or could it cause potential issues with other queries?
Update: As an alternative solution I found that you can use a hash in the create_with like Book.create_with("author" => "martin").find_or_create_by!(external_id: "1231236")
The text was updated successfully, but these errors were encountered:
Environment
rails 5.2.8.1
active_record-acts_as 4.0.3
Note: Higher versions of rails don't seem to have this issue (e.g. rails 6.1.7)
Description
I'm running into an error where when chaining the
create_with
andfind_or_create_by!
methods.I think I've traced it down to this call in the
scope_for_create
methodactive_record-acts_as/lib/active_record/acts_as/querying.rb
Line 42 in 5cc0a6a
My reasoning for thinking this is that Rails 5.2.8.1 seems to stringifies their keys in the
scope_for_create
method https://github.com/rails/rails/blob/8030cff808657faa44828de001cd3b80364597de/activerecord/lib/active_record/relation.rb#L468-L468So I overrode the
scope_for_create
method from theacts_as
gem and it seems to work fineI'll be upgrading to rails 6 eventually (where this issue doesn't exist), but in the meantime, is overriding this one line appropriate? Or could it cause potential issues with other queries?
Update: As an alternative solution I found that you can use a hash in the
create_with
likeBook.create_with("author" => "martin").find_or_create_by!(external_id: "1231236")
The text was updated successfully, but these errors were encountered: