Creating methods dynamically in a Ruby object

It feels like Rails’ makes things hard when working with models that are not AR-related, which sees to be the case lately as we are integrating more and more external services. Sometimes you have a class, say User, that defines some methods like first_name, last_name etc. and you use an object of that class in forms in your Rails app. Now imagine that in a specific form you also need to render a couple more inputs, related to the user object BUT you don’t want to define those methods in your User class. »

With pattern in Ruby

I have been using lately this nitty gritty pattern mostly inspired by Ember’s with template helper. If you have an object (usually in your .erb template) which has a long diameter it becomes a bit problematic when you have to repeat it again and again.

»

Env variables inside Ember's index.html

Using environment variables in ember is straightforward: export your env vars using any tool like direnv and import them inside your config/environment.js using node’s process.ENV.YOUR_ENV_KEY.

»

An alternative to eval

When we define a closure in Ruby (a proc or a lambda), it encapsulates its lexical scope/environment. This means that even if you define a proc in point A in code, if you pass it around and call it in point B, it will still be able to reference variables and anything that is defined inside the lexical scope of point A (where it was defined). To put it in another way, it has “(en)closed its environment”. »

Hello from Hugo

Hello from Hugo! I had tried Ghost for a while but eventually I abandonded it.. it’s funny because after leaving Jekyll for Ghost I thought I would never come back to static sites generators, yet here I am again. I have to admit that although Ghost seemed promising, its development was way too slow, plus many breaking changes: they announced 1.0.0 edition about a month ago, it’s still under very heavy development, many many things change (no breaking changes though), mostly visually and stable release date is unknown. »