NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths
Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
(defn ignore-trailing-slash | |
"Modifies the request uri before calling the handler. | |
Removes a single trailing slash from the end of the uri if present. | |
Useful for handling optional trailing slashes until Compojure's route matching syntax supports regex. | |
Adapted from http://stackoverflow.com/questions/8380468/compojure-regex-for-matching-a-trailing-slash" | |
[handler] | |
(fn [request] | |
(let [uri (:uri request)] | |
(handler (assoc request :uri (if (and (not (= "/" uri)) |
(def history (Html5History.)) | |
(.setUseFragment history false) | |
(.setPathPrefix history "") | |
(.setEnabled history true) | |
(let [navigation (listen history EventType/NAVIGATE)] | |
(go | |
(while true | |
(let [token (.-token (<! navigation))] | |
(secretary/dispatch! token))))) |
NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths
Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
gem 'dogstatsd-ruby' |
# Ruby 2.0.0 preview 1 highlights | |
# A few examples of the highlights given in | |
# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/46348 | |
# Refinements | |
# =========== | |
# create a namespaced refinement | |
module NumberQuery |
class ChangeValidator < ActiveModel::EachValidator | |
# Enforce/prevent attribute change | |
# | |
# Example: Make attribute immutable once saved | |
# validates :attribute, change: false, on: :update | |
# | |
# Example: Force attribute change on every save | |
# validates :attribute, change: true | |
def initialize(options) |
# lib/mongo_mapper_ext/mongo_mapper_soft_delete.rb | |
# | |
# Usage: | |
# class Site | |
# include MongoMapper::Document | |
# | |
# plugin MongoMapper::Plugins::DefaultScope | |
# plugin MongoMapper::Plugins::SoftDelete | |
# | |
# default_scope :deleted_at => nil |
Recently, we've been working on extracting Ember conventions from applications we're working on into the framework. Our goal is to make it clearer how the parts of an Ember application work together, and how to organize and bootstrap your objects.
Routing is an important part of web applications. It allows your users to share the URL they see in their browser, and have the same things appear when their friends click on the link.
The Ember.js ecosystem has several great solutions for routing. But, since it is such an important part of most web applications, we've decided to build it right into the framework.
If you have already modeled your application state using Ember.StateManager
, there are a few changes you'll need to make to enable routing. Once you've made those changes, you'll notice the browser's address bar spring to life as you start using your app—just by moving between states, Ember.js will update the URL automatically.