Mocking time in Jasmine specs

Posted Over 8 years ago by Henning Koch.
jasmine.github.io

The easiest way to freeze or travel through time in a Jasmine spec is to use the built-in jasmine.clock...

Detecting N+1 queries with Bullet

Posted Over 8 years ago by Dominik Schöler.
github.com

The Bullet gem is designed to help you increase your application's performance by reducing the number of queries it...

Rails 4.2 Foreign Key Support

Posted Over 8 years ago by Emanuel.

The migration DSL now supports adding and removing foreign keys. They are dumped to schema.rb as well. At this time...

JavaScript events: target vs currentTarget

Posted Over 8 years ago by Arne Hartherz.

tl;dr: Use event.currentTarget unless you are absolutely certain that you need event.target. Since it hasn't been written down...

How to capture changes in after_commit

Posted Over 8 years ago by Arne Hartherz.
leomayleomay.github.io

Your after_commit callbacks will not know about changes, as Rails discards them when committing. The linked article shows a...

little known CSS facts

Posted Almost 9 years ago by Henning Koch.

This blew my mind today: 12 Little-Known CSS Facts 12 Little-Known CSS Facts (The Sequel) Please make sure...

emcien/iso_latte

Posted Almost 9 years ago by Henning Koch.
github.com

Sometimes you need to run background jobs that you can't make important guarantees about - they may run out of...

Protip: Clone large projects multiple times

Posted Almost 9 years ago by Arne Hartherz.

Large projects usually have large test suites that can run for a long time. This can be annoying as running...

FactoryGirl: How to easily create users with first and last name

Posted Almost 9 years ago by Dominik Schöler.

In most of our applications, users have their first and last name stored in separate columns. However, specifying them separately...

How to disable auto-complete on login forms

Posted Almost 9 years ago by Tobias Kraze.

Disabling auto-complete in login forms is probably a bad idea, since it encourages weak passwords. If you are still...

Faster debugging with RubyMine macros

Posted Almost 9 years ago by Andreas Robecke.

In my RubyMine I have recorded two macros for debugging and linked them to some keyboard shortcuts. Since I believe...

Casting ActiveRecord scopes or instances to ActiveType extended model classes

Posted Almost 9 years ago by Henning Koch.
github.com

When working with ActiveType you will often find it useful to cast an ActiveRecord instance to its extended ActiveType::Record...

Rails 3 ActiveRecord::Persistence#becomes does not copy changed attributes

Posted Almost 9 years ago.

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

Databases don't order rows unless you tell them so

Posted Almost 9 years ago by Andreas Robecke.
postgresql.org

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

High Performance Browser Networking: HTTP/2

Posted Almost 9 years ago by Thomas Eisenbarth.
chimera.labs.oreilly.com

HTTP/2 will make our applications faster, simpler, and more robust—a rare combination—by allowing us to undo many of...

Querying model errors in Rails 4

Posted Almost 9 years ago by Dominik Schöler.
api.rubyonrails.org

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

sessionStorage: Per-window browser storage

Posted Almost 9 years ago by Arne Hartherz.
caniuse.com

All major browsers (IE8+, FF3.5+, Safari 4+, any Chrome) support sessionStorage, a JavaScript storage object that survives page reloads and...

Savon testing: How to expect any message

Posted Almost 9 years ago by Arne Hartherz.

When using Savon to connect a SOAP API, you may want to use Savon::SpecHelper to mock requests in your...

Customizable date (and time) picker: Rome

Posted Almost 9 years ago by Arne Hartherz.
bevacqua.github.io

Datetime picker that offers: simple UI without a specific framework several of customization options allows custom date/time validations Localization happens...

Testing setTimeout and setInterval with Jasmine

Posted Almost 9 years ago by Henning Koch.
jasmine.github.io

Jasmine has a jasmine.clock() helper that you can use to travel through time and trigger setTimeout and setInterval callbacks:

ActiveRecord: How to use ActiveRecord standalone within a Ruby script

Posted Almost 9 years ago by Thomas Klemm.
gist.github.com

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

PostgreSQL vs MySQL: How to UPDATE using a JOIN

Posted Almost 9 years ago by Arne Hartherz.

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

PSA: "index: true" in Rails migrations does not work as you'd expect

Posted Almost 9 years ago by Arne Hartherz.

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

Ruby bug: Symbolized Strings Break Keyword Arguments in Ruby 2.2

Posted Almost 9 years ago by Dominik Schöler.
bugs.ruby-lang.org

TL;DR Under certain circumstances, dynamically defined symbols may break keyword arguments in Ruby 2.2. This was fixed in Ruby...