Skip to content

Instantly share code, notes, and snippets.

@raj454raj
raj454raj / flashhash_override_3_0.rb
Last active May 20, 2020 09:19
FlashHash override in Rails 3.0.20 code to support flashes created in Rails 3.2.22 (https://raj454raj.wordpress.com/2016/08/13/flashhash-issue-rails-upgrade/)
# This patch handles both types of flashes that are created in
# Rails 3.2.22 as well as those created in Rails 3.0.20
ActiveRecord::SessionStore::Session.class_eval do
def self.unmarshal(data)
return unless data
marshalled = nil
begin
@raj454raj
raj454raj / class_var.rb
Created August 27, 2016 05:56
Class variables in Ruby
class Temp
@@count = 0
def initialize
@@count += 1
end
def self.count
@@count
end
end
@raj454raj
raj454raj / flashhash_override.rb
Last active September 1, 2016 20:28
FlashHash override to handle both kinds of flashes i.e created in Rails 3.0.20 as well as in Rails 3.2.22. Put this config/initializers/. Kept with Rails 3.2.22 code.
# Supports both kind of flash messages (Rails 3.0.20 and 3.2.22)
# It converts Hash type of flash messages to Object type of flashes
ActiveRecord::SessionStore::Session.class_eval do
def self.convert_to_3_2(flash_data)
return unless flash_data
flash_new = ActionDispatch::Flash::FlashHash.new