iana.org

When using send_file (for example for attachments of any kind), make sure your application knows the correct mime types...

You can freeze any Ruby object to prevent further modification. If you freeze an ActiveRecord and try to set an...

If you want to grow a Ruby Array, you might find out about #fill but it is not really what...

makandra dev

Code folding is a very useful feature to me. It gives me a quick overview over a file and keeps...

When using threads, you must make your code thread-safe. This can be done by either locking (mutexes) all data...

Today I learned that Ruby on Rails has shipped with a built-in slug generator since Rails 2.2:

makandra dev
github.com

Nested exceptions for Ruby: When you rescue an error and then re-raise your own, you don't have to...

Web applications can be used by multiple users at the same time. A typical application server like Passenger has multiple...

If you need to log to a file you can use Ruby's Logger class: require 'logger'

This is useful to kill processes like ruby my-script.rb: pkill -f my-script.rb With great power comes great responsibility.

If you're on Ruby 2.3+ there's a <<~ operator to automatically unindent HEREDOCs: str = <<~MESSAGE Hello Universe!

If you want to sort values from an enumerable into two arrays based on whether they match a certain criteria...

xaprb.com

The linked article explains how to get a database-wide lock without creating table rows: This article explains how I...

nandovieira.com

Postgres 9.4 introduces a new column type: jsonb. json and jsonb columns store data differently, so just compare the two...

Enumerable#count can do three things. With no argument provided, it returns the number of items. With an argument, it...

Array#flatten by default flattens an array recursively. To only flatten the array for e.g. one level, it takes an...

coffeescript.org

The Javascript in operator does what Hash#has_key? does in Ruby: Return whether an object has a property.

To find a hash key by it's value, i.e. reverse lookup, one can use Hash#key. It's available...

With ActiveSupport you can say: class Robot def self.likes_humans? 'Nope.' end delegate :likes_humans?, to: :class end Robot.likes_humans...

github.com

Jonas Nicklas, the author of Carrierwave and Capybara, has released Refile, a gem for handling file uploads in Rails. It...

makandra dev
databound.me

Databound provides Javascript a simple API to the Ruby on Rails CRUD. Tries to expose a full model CRUD as...

edgeguides.rubyonrails.org

Rails guide that covers PostgreSQL-specific column types and usages for Active Record. You should especially keep in mind the...

makandracards.com

Chances are you're seeing the warning repeated a lot of times, maybe thousands of times. Here's how to...

If you want a class-like construct in JavaScript, you can use the module pattern below. The module pattern gives...