Rails 3.2 and Active Record Store
What exactly is Active Record Store and how to use it with Rails 3.2
Rails 3.2 was released earlier today and it provides a variety of new features including: Active Reload, Faster Dev Mode, Tagged Logger and, of coarse, Active Record Store. When Active Record store was released I was a bit curious as to how it works since I only saw the same example on every blog out there and the example itself just wasn’t doing it for me. Therefore this article will briefly explain how to use Active Record Store and how the contents of are stored in the database.
(more…)
Rails Page Caching and Internationalization
How to hack your Rails application to configure how page caches are stored
Rails offers an effective caching solution for caching pages using page_caching. This stores the entire output of a request into a publicly accessible file which is then picked up by the web server first before the request is made to Rails. The Rails default method to set the path of the is something that doesn’t take the locale nor the subdomain into consideration. So if you have a subdomain that is bound to the same Rails server, then the page caching will not append any of that to the name of the cached page file. This blog article will explain how to change this behaviour.
(more…)
Getting started with MooTools Behavior.js
A simple tutorial that explains the steps to get you started with Behavior.js
MooTools offers an elegant solution to dealing with messy, unusable JavaScript code that is used to build simple, disposable UI effects and elements, that should normally be abstracted from your application code, with the use of a library called Behavior.js. The library contains two main tools: Behaviour which is used for mapping layout elements to classes (plugins) and Delegator which is used to relate the options identified in HTML elements to predefined, reusable filters (subroutines).
This article will go through the steps involved with getting this awesome plugin working with your application.
Use Gistex to load up Github Gist Snippets
Gistex is an easy to use tool to spawn up Github Gist snippets using AJAX
The other day I decided on embedding Github Gist code snippets into yearofmoo instead of regular home-grown code blockquote areas. Gist is awesome, but the standard Javascript embeds do not work with a pure ajax website (like this one). So the only way to get them to work was todo some voodoo JavaScript and then … voila … Gistex was born.
(more…)
Current state of onhashchange & HTML5 history
How widely supported are these URL changing techniques in modern browsers?
The onhashchange event is a popular event and has been widely looked into by yearofmoo. The MooTools-onhashchange plugin offered by yearofmoo takes care of this task effectively. The onhashchange event can be used in combination with a hash-prefixed URL token, known as a hashbang, to effectively inform search engines of indexed ajax content.
The HTML5 history API is only offered by modern browsers and offers more features than the onhashchange event. The only issue is that not all browsers fully support it yet since it is a new HTML5 JavaScript API. In addition, unlike with the onhashchange event, there is no way to emulate or hack non-supporting browsers to offer popstate support.
But how widely supported are the two features?
Rails page caching in a separate directory
How to setup Apache or NGINX to be aware of where rails stores page caches
Rails offers a really powerful caching technique where the contents of an entire page load will be stored into a HTML file. This is incredibly useful for performance enhancements for big and small Rails apps.
One issue, however, is that when you setup page caching into a different directory which isn’t the public folder root, then the generated HTML files won’t be picked up by Apache, Nginx, or whichever HTTP daemon you’re webserver is running since the direct path is different. Therefore, to get this to work properly, some tweaking needs to be done on the HTTP daemon so that it recognizes the caching directory path.
The nice thing is that when the caching files are in a subfolder within the public root folder then management of the cache as a whole becomes much easier. This is explained in detail here.
This article will quickly explain how to setup Rails and the HTTP daemon (Apache or Nginx) to properly behave with the cache change.
Serve Precompiled Rails Assets from a Static Domain
Precompile and deliver your Rails assets from a different domain for static content
With the release of the Rails 3.1 Asset Pipeline, which uses Sprockets to deliver Sass and Coffeescript rendered assets, the development of properly organized assets in Rails just got much easier. Now there exist many tutorials out on the web that go into detail about how to play around with this new feature, so I’m not going to go into detail about how todo that. What I will cover is how to setup a static domain, that does not interfere with your Rails daemon, that serves these assets quickly and smoothly.
Last minute fix for Rails 3.1 Stable
Beware of the config.assets.digest fingerprinting defaults!
As you all might be well aware, Rails 3.1 was released yesterday (August 31st 2011) … and for those of you whom have been developing using the Rails 3.1 beta and RC versions, you may have noticed a small gotcha which occurred in the Rails production configuration that may affect your asset filenames. If you notice that your asset file names are missing a fingerprint hash, md5 token, digest, hash timestamp (or whatever you want to call it) within their filename … like application-xxxxxx.js then the reasoning behind this is because Rails 3.1 disables the config.assets.digest option by default for all environments.
MooTools Asset.stylesheet onload event patch
A fully working fix for the onload event on the MooTools Asset.stylesheet library
The Asset.stylesheet library itself is a very useful library for preloading stylesheets via JavaScript. The only problem is that it does not support the onload event for all browsers. The reasoning behind this is because the onload event itself is not supported on all browsers; an older article posted on yearofmoo.com went into full detail about this problem. This blog article, however, provides the code for MooTools 1.2 and 1.3 that patches the Asset.stylesheet library to support the onload event 100% in all browsers.
Element rotation using Fx.Rotate
Perform quick and dirty rotations using the Fx.Rotate plugin
Yearofmoo.com has now released the Fx.Rotate plugin which allows for cross-browser rotation using CSS3 transforms and IE filter properties. The class itself is a subclass of the super powerful MooTools Fx class which provides tons of functionality for controlled transitions and callbacks.