Note: ActiveRecord::Base#becomes has a lot of quirks and inconsistent behavior. You probably want to use ActiveType.cast instead.

guides.rubyonrails.org

Starting from 4.1, Rails automatically detects the inverse of an association, based on heuristics. Unfortunately, it does not seem to...

postgresql.org

There is no such thing as a "default order" of rows in database tables. For instance, when you paginate a...

makandra dev
api.rubyonrails.org

ActiveModel supplies an errors object that behaves similar to a Hash. It can be used to add errors to a...

makandra dev
semaphoreci.com

Capistrano 3 is a major rework of the framework and requires several adjustments to your deploy configuration files. The biggest...

Please don't use the horrible datetime_select helper. It has a terrible UI. Always prefer to use a visual...

You might wonder about this request in your test.log: Started GET "/__identify__" for 127.0.0.1 at 2015-04-29 18:00...

gist.github.com

Re-creating a complex ActiveRecord scenario quickly without setting up a full-blown Rails app can come in handy e.g...

Several Rails migration methods accept index: true as an option to create an index. In some cases (like #add_column...

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...

Rails comes with a Rake task notes that shows code comments that start with "TODO", "FIXME", or "OPTIMIZE".

edgeapi.rubyonrails.org

Starting from Rails 4.0, you can use a special form options helper called #collection_check_boxes. It behaves similar to...

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

You know that ActiveRecord caches associations so they are not loaded twice for the same object. You also know that...

makandra dev

Now supports RSpec 3 and Rails 4 Drops support for state_machine, which has some issues with Rails 4 and...

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

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

makandra dev
relishapp.com

RSpec 3 has verifying doubles. This breed of mock objects check that any methods being stubbed are present on an...

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

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

railscasts.com

See this Railscast. Basically you can simply write views like index.xlsx.erb: ID Name Release Date Price <% @products.each do |product| %> <%= product.id...

To achieve this goal you have to setup the session store like the following example: MyApp::Application.config.session_store( :cookie_store...

nandovieira.com

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