Skip to content

Instantly share code, notes, and snippets.

View vijayagrawal18's full-sized avatar

Vijay Kumar Agrawal vijayagrawal18

View GitHub Profile
@vijayagrawal18
vijayagrawal18 / flatten.rb
Created November 18, 2017 00:02
Flatten Ruby Array
def flatten arr
return [arr] unless arr.is_a? Array
arr.inject([]) do |flattened, element|
flattened += flatten(element)
end
end
@vijayagrawal18
vijayagrawal18 / changing_foreign_key_fails_to_update_association.rb
Last active March 22, 2016 12:31
Changing foreign key fails to update cached association if record was loaded through association
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# Activate the gem you are reporting the issue against.