state_machine: One machine to rule them all? | PluginAWeek
After 2 1/2 years of blood, sweat, tears, and the occasional Jägermeister, I’m finally officially announcing a project I’ve been quietly working on: state_machine.
Related cards:
ASDF: A Version Manager To Rule Them All
tl;dr
asdf
allows you to manage multiple runtime versions with a single CLI tool and is backwards compatible by supporting existing config files, like e.g..nvmrc
or.ruby-version
.
Getting Started
- Disable rbenv
1.1 Dele...
How to make changes to a Ruby gem (as a Rails developer)
At makandra, we've built a few gems over the years. Some of these are quite popular: spreewald (> 1M downloads), active_type (> 1M downloads), and geordi (> 200k downloads)
Developing a Ruby gem is different from developing Rails applications, w...
Why developers should be force-fed state machines
Most web applications contain several examples of state machines, including accounts and subscriptions, invoices, orders, blog posts, and many more. The problem is that you might not necessarily think of them as state machines while designing your...
How to add esbuild to the rails asset pipeline
This are the steps I needed to do to add esbuild to an application that used the vanilla rails asset pipeline with sprockets before.
Preparations
- update Sprockets to version 4
- add a
.nvmrc
with your preferred node version (and instal...
Ruby and Rails deprecation warnings and how to fix them
Add deprecation warnings and their solution or link to available solutions.
Global access to Rake DSL methods is deprecated. Please include Rake::DSL into classes and modules which use the Rake DSL methods.
---------------------------------------...
Rails: Flagging all cookies as secure-only to pass a security audit
Why secure-only cookies used to be necessary
Cookies have an optional secure
flag. It tells the browser to not send the cookie f...
Hack of the day: One-liner to run all Cucumber features matching a given string
The following will search for all .feature
files containing a search term and run them using geordi.
find features/ -name '*.feature' | xargs grep -li 'YOUR SEARCH TERM' | sort -u | tr '\n' ' ' | xargs ...
How to get the hostname of the current machine in Rails or a Ruby script
Use Socket.gethostname
. So for a machine whose hostname is "happycat", it will look like this:
>> Socket.gethostname
=> "happycat"
That should work right away for your Rails application. For plain Ruby, you first need to do:
requi...
Apache: Redirect all requests from one host to another
In order to redirect all requests from redirecting-host.com
to desired-host.com
while keeping path and query params unchanged, change your Apache VHost to something like this:
ServerName desired-host.com
ServerAlias redirecting-host.c...
Hack of the day: One-liner to run all changed Cucumber features
Similar to our snippet that runs all Cucumber features matching a given string, the following will run all modified or new Cucumber features by looking at your git status:
git status --short | grep -v '^ D ' | grep '.featur...