RubyMine: Accessing views and partials from controllers

RubyMine links controller methods to their views and partials through gutter icons, making navigation between Rails controllers and templates faster.

Why a Rails flash message is shown twice

Flash messages can appear twice when render is used instead of redirect_to; flash.now is for the current request, flash[] for the next one.

HTTP 302 redirects for PATCH or DELETE will not redirect with GET

Browsers may keep PATCH and DELETE on 302 redirects instead of switching to GET, breaking AJAX flows. Use 303 See Other or POST method override to force a GET follow-up.

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.

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.

Rails: Postgres Partial Indexing

PostgreSQL partial indexes reduce index size and write overhead by indexing only rows that match a condition, useful for conditional uniqueness and large tables.

Best practice: How to manage versions in a Gemfile

Gem version pins in Gemfile are usually unnecessary because Gemfile.lock fixes installed versions; use constraints only for lockfile-free setups, known regressions, or blocked upgrades.

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.

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.

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.

CarrierWave: Default Configuration and Suggested Changes

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

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.