For some reason you want to define a find condition in array form. And in that condition both column name...

Find conditions for scopes can be given either as an array (:conditions => ['state = ?', 'draft']) or a hash (:conditions => { 'state' => 'draft...

There are many different methods that allow mapping an Array to a Hash in Ruby. Array#to_h with a...

When Paperclip attachments should only be downloadable for selected users, there are three ways to go. The same applies to...

This will show you how to create a RSS feed that the Feed Validator considers valid. Note that RSS is...

In modern Rails versions you can also use ActiveRecord's pluck method. User.active.pluck(:id) => [1, 5, 23, 42]

github.com

delocalize provides localized date/time and number parsing functionality for Rails.

When you load a record with find options that have SQL fragments in :select or :joins, ActiveRecord will make that...

emphaticsolutions.com

In a great post about named routes in Rails, path vs. url, Viget Labs ponders which variant is best used...

github.com

This gem is designed to provide CSS views to Rails, and a process to concatenate and minify these files to...

yehudakatz.com

This post explains, in some detail, how we will implement a nice performance boost for Rails developers. Understanding the details...

Expiration of Rails sessions By default Rails sessions expire when the user closes her browser window. To change this edit...

github.com

By default, Cucumber uses mocha. This note shows to use RSpec stubs and mocks instead. Rspec 1 / Rails 2

Call with the server's hostname (and user if you have no SSH agent), e.g. install-gems-remotely my.server.com

Rails 3, 4, 5, 6 config/application.rb config/environment.rb before the initialize! call (we don't usually edit this file)

makandra dev

Update RubyGems and Passenger Bundler requires Rubygems >= 1.3.6. Run gem update --system if you have an older version.

This might eventually be fixed by Rails itself.\ Right now this is the way to have the rails_xss plugin...

Sometimes you want to fetch associations for an ActiveRecord that you already loaded, e.g. when it has deeply nested associations...

github.com

There are three ways to define your own RSpec matchers, with increasing complexibility and options: 1) Use RSpec::Matchers.define

Sometimes files attain executable-flags that they do not need, e.g. when your Windows VM copies them over a Samba...

When deploying Rails applications you might have noticed that JS and CSS are not cached by all browsers.

When working with times and dates in Rails applications, you need to deal with the following problem: In Rails, Time...