...at the same time have a .where on an included table, two things happen: Rails tries to load all involved records in a huge single query spanning multiple database tables...
activity.users.ids # here happens the unexpected # => [4] Workarounds Preload separately In newer Rails versions you should prefer to use joins and then preload if necessary (which will trigger a...
...for old IEs. Unfortunately, their auto-loading mechanism may not work properly on your Rails application due to the asset pipeline. They use FileAPI, so you could just include it...
...you. It likely will. The sandbox has one caveat: When Claude Code detects a Rails application, the config directory becomes read-only for Claude's BashTool by default and there...
...database.yml to look roughly like this: default: &default adapter: postgresql encoding: unicode pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %> development: <<: *default <%= 'host: localhost' unless ENV['SANDBOX_RUNTIME'] %> database: your_app_development...
...model validation that restricts its length. There are two motivations for this: In modern Rails, database types :string and :text no longer have a relevant size limit. Without a validation...
...malicious user can quickly exhaust the hard drive of your database server. In legacy Rails (or database schemas migrated from legacy Rails), database types :string and :text had a database...
...part is a bit lengthy, but it allows you to debug strange bugs with Rails autoloading the wrong constants. Due to the constant lookup rules above, Rails sometimes guesses wrong...
...in development and production, but the problem exist for both environment. Development During development, Rails unloads all classes after every request. This way code changes take effect immediately, without requiring...
When a Rails controller action should handle both HTML and JSON responses, do not use request.xhr? to decide that. Use respond_to. I've too often seen code like this...
...load associated records if you know you need to access them later on. The Rails docs say: Eager loading is supported with polymorphic associations. This is true, but has some...
...and include their current versions' primary media... Page.includes(:current_version => :primary_medium).to_a ... Rails will produce 4 queries: Page Load (0.7ms) SELECT "pages".* FROM "pages" PageVersion Load...
gem 'super_diff' Require it in your spec_helper.rb require 'super_diff/rspec' # For Rails applications you can replace this with 'super_diff/rspec-rails' Customize colors in spec/support/super_diff.rb SuperDiff.configure do |config...
...contain exactly "XXX" ActiveRecord::Base is monkey patched by super_diff/rspec-rails (includes rspec and rails) super_diff/rails (includes active_record and active_support) super_diff/active_record This means that you have...
Recent rails security updates have shown that people make incorrect assumptions about the possible contents of the params hash. Just don't make any! Treat it as what it is...
.../pages/edit?foo --> params == {:foo => nil} /pages/edit?foo[] --> params == {:foo => [nil]} # at least in older rails 3 and in rails 2.x Be especially wary about stuff like User.find_by_password...
Arel is a library that was introduced in Rails 3 for use in constructing SQL queries. Every time you pass a hash to where, it goes through Arel eventually. Rails...
If you have an integer and want to use it to represent an element's position (like "1st" for 1...
When you try to remove a non-existing index using remove_index, the migration will incorrectly pass without an error...
Shortener is a Rails Engine Gem that makes it easy to create and interpret shortened URLs on your own domain from within your Rails application. Once installed Shortener will generate...
If you turn on stylesheet caching, it might happen that stylesheets from different locations with different relative pathes will be...
If you parse this Yaml ... yes: 'Totally' no: 'Nope' ... you get this Ruby hash: { true: 'Totally', false: 'Nope' }
...identity map for ActiveRecord. Ruby 1.8.x support will be dropped with or after Rails...
There is a problem with AJAX response handling for Rails 3 remote links and forms in Internet Explorer. This problem affects applications still using jQuery...
SSL in Rails 3 is non-obvious...
This gem is designed to provide CSS views to Rails, and a process to concatenate and minify these files to one file for production...
...post explains, in some detail, how we will implement a nice performance boost for Rails developers. Understanding the details might help gain the full benefits of the optimization, but you...
...walk you through the I18n API and contains a tutorial how to internationalize a Rails application from the start...
YAML List of all translations currently available in Rails
List of Rails releases...
I just finished reviewing Rails 2.3 Nested Object Forms. While a very nice and “magical” feature, I’ve got to admit that I’m really not that crazy about how...