Skip to content

Instantly share code, notes, and snippets.

@eins78
Created September 14, 2015 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eins78/656a1f7907da6378aae3 to your computer and use it in GitHub Desktop.
Save eins78/656a1f7907da6378aae3 to your computer and use it in GitHub Desktop.
rails controller instance var is cached if initialy assigned to const
class FooController < ApplicationController
KONST = {
foo: { bar: 'baz' },
}
def show
@konst = KONST
end
end
# --- in View: ---
# :ruby
konst = @konst.map do |key, value|
value[baz] = 'oops'
[key, value]
end.to_h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment