Make Makandra Consul work with RSpec 2.x and Rails 3.x

Using Consul’s authorization matcher with RSpec 2.x on Rails 3.x can fail because of version incompatibilities. Compatibility requires adapting the matcher setup.

Caching file properties with ActiveStorage Analyzers

Slow PDF property lookup can avoid repeated downloads by caching intrinsic file metadata such as page count on ActiveStorage::Blob and using custom analyzers for shared uploads.

Regex: Be careful when trying to match the start and/or end of a text

Regular expressions can accept embedded newlines when ^ and $ are used; \A and \z anchor the whole string and avoid unsafe validation matches.

Deal with error: Expected foo_trait.rb to define FooTrait

Rails autoloading can surface a misleading Expected foo_trait.rb to define FooTrait error after a mistake in an unrelated trait, making the real failure hard to locate.

IRB: last return value

IRB and the Rails console store the previous command result in _, making it easy to reuse a forgotten value without rerunning the expression.

YAML syntax compared with Ruby syntax

YAML and Ruby have different syntax, and YAML aliases and merge keys often matter when writing Rails locale files. Duplicate keys override earlier values instead of merging nested content.

PDF Generation in Rails

Generating PDFs in Rails often means choosing between text-based reports, HTML-to-PDF rendering, and different trade-offs in layout control and browser fidelity.

[jruby] TruffleRuby Status, start of 2017

TruffleRuby is an experimental Ruby implementation pursuing much faster execution than MRI, with progress on Rails support, startup time, and JVM independence.

Concerned about Concerns?

Rails Concerns help break up oversized Active Record models, but their trade-offs and community debate make them a contested choice.

How to update a single gem conservatively

Updating one gem with bundle update can pull in dependency upgrades and break existing code. Bundler --conservative limits changes to the targeted gem and avoids unnecessary transitive updates.

Check if an object is an ActiveRecord scope

Checking for an ActiveRecord scope with is_a?(ActiveRecord::NamedScope::Scope) breaks in Rails 3 and misses unscoped model classes. respond_to?(:scoped) is a broader check.

CarrierWave: Default Configuration and Suggested Changes

CarrierWave defaults often need project-specific tweaks for storage paths, cache cleanup, test isolation, and large-file handling.

The asset pipeline does not like files that look like fingerprints

Rails asset precompilation can ignore files whose names resemble fingerprints, causing fonts or other assets to vanish from the pipeline.

Markdown-like emphasizing for text fields

Lightweight emphasis for text fields without full Markdown, replacing **text** with <strong>text</strong> in Rails views.

Boolean fields in migrations

Updating boolean columns in a migration needs database-specific true/false values; quoted_true and quoted_false return the correct representations in Rails.

Iterate over every n-th element of a Range in Ruby

Use Range#step to visit every n-th value in a Ruby range, useful for date sequences such as weekly Mondays. Rails and ActiveSupport return an array when no block is given.

The many gotchas of Ruby class variables

Ruby class variables are shared across inheritance hierarchies and bind to the current scope at parse time, making them hard to control and easy to misuse.

How everyone is inserting technical debt in their applications | Plataforma Tecnologia Blog

This means Basecamp migrated from the first Rails release up to the edge one. So how come people say so frequently how hard is to update their applications from Rails 2.1 to Rails 2.2? And the answer is simple: plugins.

rspec_candy 0.4.0 released

rspec_candy 0.4.0 adds support for RSpec 3 and Rails 4, while dropping the unmaintained state_machine integration.

Default views in Rails 3.0 with custom resolvers

It is common in Rails 3.0 applications that you want to provide default views for a group of controllers. Let’s say you have a bunch of controllers inside the Admin namespace and you would like each action to fallback to a default template. So if you are rendering the index action for Admin::PostsController and “app/views/admin/posts/index.html.*” is not available, it should then render “app/views/admin/defaults/index.html”.

Since Rails 3.0, we have a new abstraction called resolvers that holds the logic to find a template.

Ruby tempfiles

Temporary files in Ruby are removed automatically when no reference remains, and early unlink prevents stale paths and unauthorized access.

Bootswatch: Paper

Free Bootstrap theme with a Material Design look for Rails apps. Sass and Less files simplify integration, while the CSS-only approach keeps the theme easy to replace.

Deliver Paperclip attachments to authorized users only

Private Paperclip downloads need restricted storage or hashed URLs to keep attachments away from public access. A controller-based delivery path or secret-based paths reduce exposure.

Use the contents of a WordPress database in your Rails app

These two models can be used to access the posts and associated comments of a WordPress database.