gist.github.com

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

When you want to UPDATE a table with information from an associated table, you can JOIN the associated table into...

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

# Given the following models class Image < ActiveRecord::Base has_many :album_images has_many :albums, through: :album_images

When ending a Selenium test Capybara resets the browser state by closing the tab, clearing cookies, localStorage, etc.

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

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

Write a // and indent every subsequent line by two spaces. This is great for documenting BEM blocks! // An action button...

SELECT table_name, table_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'your_database' order by table_rows;

Obviously, you only can do this for your own sites. You need to authenticate a domain you want to remove...

xaprb.com

The linked article explains how to get a database-wide lock without creating table rows: This article explains how I...

The CSS property z-index is not as global as you might think. Actually, it is scoped to a so...

tldr; Use git diff -M or git diff --find-renames when you've moved a few files around. Usage

If you want to load an SQL dump from an ActiveRecord migration, you might find this to be harder than...

markembling.info

Using uncountable resources is not recommended as it breaks Rails' magic, e.g. when using form_for. You'll always be...

In the tradition of our PostgreSQL cheat sheet for MySQL lamers, here is a cheat sheet for Jasmine when you...

developer.mozilla.org

You can do so much more than console.log(...)! See the attached link for a great breakdown of what the developer...

edgeguides.rubyonrails.org

Rails guide that covers PostgreSQL-specific column types and usages for Active Record. You should especially keep in mind the...

makandra dev

The Rails asset pipeline improves delivery of application assets (javascripts, stylesheets, images, fonts). Here are some basic facts about its...

Creating records in specs can be so fast that two records created instantly after one another might have the same...

We upgraded a Rails 2 application to Rails 3.2 and Ruby 2.1, changed the mysql adapter from mysql to mysql2...

p ActiveRecord::Base.connection.indexes(:table_name)

tl;dr: Use with_index ActiveRecord's find_each with index If you do not provide a block to find...

api.rubyonrails.org

To avoid n+1 queries, you want to eager-load associated records if you know you need to access them...