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
>> Request => Request(id: integer, inserts: integer_array, updates: integer_array) >> r = Request.new => #<Request id: nil, inserts: [], updates: []> >> # These array columns have an empty array set as default! >> r.inserts => [] >> # This doesn't work >> r.inserts << 7 => [7] >> r.inserts => [] >> # But this does >> r.inserts += [7] => [7] >> r.inserts => [7] >> # And now, this too >> r.inserts << 9 => [7, 9] >> r.inserts => [7, 9]
The text was updated successfully, but these errors were encountered:
I basically just do r ||= [] before every insert like so:
r ||= []
r ||= [] r << 7
Sorry, something went wrong.
I basically just do r ||= [] before every insert like so: r ||= [] r << 7
Tried this and got weird bug that in some cases it didn't work. When I do:
object.array_attribute = [] object.array_attribute << value
than object.array_attribute # => [value]
object.array_attribute # => [value]
But if I do
object.array_attribute ||= [] object.array_attribute << value
than object.array_attribute # => []
object.array_attribute # => []
I think in case of ||= [], object.array_attribute have some value, but it is not the []. IDK, maybe this is some serialization issue.
In the end went with old good
object.array_attribute = object.array_attribute << value
No branches or pull requests
The text was updated successfully, but these errors were encountered: