Global variables in Rails

An article, posted about 5 years ago filed in global, variables, rails, ruby & ruby on rails.

A quick note, because I was using the wrong search terms. If you want to share e.g. the current user of an app with a model you can now (since Rails 5.2) use a model inheriting from ActiveSupport::CurrentAttributes. Before you were required to pass this current user explicitly or find another way to access state.

Note that this can either be a good thing or a bad thing (tl;dr: thread-local global state makes apps unpredictable)

And even the docs warn against abusing this feature. Powerful tools can come with dangerous consequences :) Global variables are immensely powerful. Use with care. I'm not even sure if I'm going down this path…

Continue reading...

Het gemak van waarheid

An article, posted almost 15 years ago filed in al gore, global, nl, truth, waarheid & warming.

Even goed en rustig lezen, Louise O. Fresco over films als An Inconvenient Truth en de nieuwe Food, Inc. (trivia: beiden hebben (o.a.) dezelfde uitvoerende producent):(…) als je een geweten hebt, dan mag je niet de nodige nuance aanbrengen en zeggen dat modernisering en technologie niet per definitie fout zijn en juist ook veel goeds gebracht hebben. Dan zwijg je, om niet de verdenking op je te laden dat je geen hart hebt. Zo is een nieuwe tirannie ontstaan, die van de onweersproken kritische klasse. En dat is de meest ongemakkelijke waarheid.Samengevat gaat haar betoog over het marginaliseren van de foutjes door kritische media die in films zitten als An Inconvenient Truth. Ongeacht van de belangrijkste boodschap, klimaatverandering is gaande, kun je je afvragen waarom er 'foutjes' gemaakt moeten worden. Om dat verhaal net iets schokkender aan te kunnen zetten? Het is teleurstellend dat mensen die claimen de waarheid te spreken, zelf toch ook lichtzinn…

Continue reading...

murb blog