Materialized views with Sequel
Sequel Show archive.org snapshot is an awesome ORM such as ActiveRecord. The linked article describes how easily you can implement and use materialized views Show archive.org snapshot with postgres as your underlying database.
Related cards:
Effectively Using Materialized Views in Ruby on Rails · pganalyze
It's every developer's nightmare: SQL queries that get large and unwieldy. This can happen fairly quickly with the addition of multiple joins, a subquery and some complicated filtering logic. I have personally seen queries grow to nearly one hun...
ActiveRecord meets database views with scenic
Using Scenic, you can bring the power of SQL views to your Rails application without having to switch your schema format to SQL. Scenic provides a convention for versioning views that keeps your migration history consistent and reversible and av...
Freeze (vendor, unpack) a single Ruby gem with and without Bundler
When you need to patch an existing gem, one way is to "vendor" the gem by copying it into the vendor/gems
directory of your Rails project. You can then make any changes you require and Rails will use the vendored version of the gem after a serve...
Working with or without time zones in Rails applications
Rails supports time zones, but there are several pitfalls. Most importantly because Time.now
and Time.current
are completely different things and code from gems might use one or the other.
Especially configuring an application that cares only...
PSA: When Redis (on LRU noeviction) reaches memory limits, keys with (any) expiry are removed, and keys without are not
In production, you (or your ops team) should configure a maximum number of bytes that Redis can use to store data (maxmemory
setting).
They may even want to set maxmemory-policy
to noeviction
to avoid keys being removed that you want to keep...
Perform HTTP basic authentication in Cucumber (with or without Selenium)
This card describes a Cucumber step that lets you say:
When I perform basic authentication as "username/password" and I visit the admin area
The path component ("... the admin area") is parsed through your path_to
helper in `features/s...
Default views in Rails 3.0 with custom resolvers
It is common in Rails 3.0 applications that you want to provide default views for a group of controllers. Let’s say you have a bunch of controllers inside the Admin namespace and you would like each action to fallback to a default template. So if ...
Rails 2.3.x sometimes renders localized views with the wrong content type
Under certain (unknown) circumstances, Rails will give localized files an invalid content-type in the Response header. For me, after requesting corporate_information
and rendering corporate_information.de.html.haml
, Rails sent a content-type o...
What's wrong with defining JavaScript variables within if blocks? - Stack Overflow
Because javascript has something called "Hoisting" which makes your code do things it doesn't look like it should be doing. Basically, that means a javascript interpreter will move all var declarations, regardless of where they are in the body of ...
Rails: When defining scopes with class methods, don't use `self`
Sometimes it is useful to define a named scope by implementing a static method with the scope's name on the scoped class. For instance, when a method should decide which existing scope should be the next link in the scope chain. Take this class fo...