Content tagged “Ruby on Rails”

  1. PostgreSQL Quick Tips: Working With Dates Using EXTRACT function

    A handy tip here from Karol Galanciak demonstrating how to use PostgreSQL’s EXTRACT function:

    We can use EXTRACT and now() functions—the former could be used for extracting the current year from a timestamp and the latter could be used for getting the current time.

    Order.where("EXTRACT(year FROM created_at) = EXTRACT(year FROM now())")
  2. Launching FrancisCMS onto the IndieWeb

    About a month ago, I quietly launched a new version of this site. It’s been in the works for quite some time.

    Published on .

  3. Chunked transfer encoding in Rails (streaming)

    Using the Transfer-Encoding: chunked header, the server will send chunks of the rendered page back to the browser so in the case of Rails, it starts with the layout and sends out the <head> part including assets like js and css.

    Chunked transfer encoding is a great way to improve page performance for the parts of your application that require time-consuming database queries. The Rails-level changes are straightforward, but unfortunately not all Ruby web servers support the feature (looking at you, Puma).

  4. Extending Paul Irish's comprehensive DOM-ready execution

    Way back in March of '09, Paul Irish laid forth a markup-based means of executing JavaScript on page load. I iterated on Paul's method, adding a touch of HTML5 and making use of some built-in Rails magic.

    Published on .

  5. JavaScript dependency management and concatenation: Sprockets

    Sprockets is a Ruby library that preprocesses and concatenates JavaScript source files. It takes any number of source files and preprocesses them line-by-line in order to build a single concatenation. Specially formatted lines act as directives to the Sprockets preprocessor, telling it to require the contents of another file or library first or to provide a set of asset files (such as images or stylesheets) to the document root. Sprockets attempts to fulfill required dependencies by searching a set of directories called the load path.

  6. Jammit: Industrial Strength Asset Packaging for Rails

    Jammit is an industrial strength asset packaging library for Rails, providing both the CSS and JavaScript concatenation and compression that you’d expect, as well as YUI Compressor and Closure Compiler compatibility, ahead-of-time gzipping, built-in JavaScript template support, and optional Data-URI / MHTML image embedding.