Notes posted by dvdplm

RSS feed
January 31, 2012 - (v3.0.0 - v3.1.0)
0 thanks

undocumented events/symbol/types

@nessur is right: drop the “before_” and “after_” prefixes and you have the possible values for the uninformatively named `symbol` param: create, save, update and validate.

So to remove all validations for a model do: `reset_callbacks :validate`

November 10, 2009
2 thanks

Where are the cached files?

If you configure your app to use the file_store like so:

config.cache_store = :file_store, '/tmp'

and expect you cached page pages to end up in /tmp, think again…

Rails – rather obscurely imho – will store page cached pages in the public/ folder of your app, making it easy for your webserver to find them.

The ‘page_cache_directory’ used in the ‘page_cache_path’ method above is a class var that defaults to the public/ dir.

April 1, 2009
0 thanks

Conflicts with 1.8.7 (and 1.9.1)

“abc”.to(0) fails in 1.8.7 and “String” should be “String” (or “abc”). Using to_a breaks in 1.9.1.

I’m using “abc”. :(

March 9, 2009
0 thanks

Memoize will not cache singleton methods

The following does not work:

class PersonType < ActiveRecord::Base
  extend ActiveSupport::Memoizable
  class << self
    def mister
    memoize :mister

I guess one could extend the superclass, Class, with Memoizable support, but that seems Evil.

February 5, 2009
1 thank

Weird method...

Takes three params:

- a Class constant (has to be an existing class)
- a "tag" param that, if set to "tag:yaml.org,2002:binary" will call unpack("m") on the third parameter, val; any other values for tag are ignored
- val can be a Hash or a String; if it's a string it is wrapped in a hash {'str' => val}, other wise...
  1. an instance of klass is allocated

  2. an instance of string is initialized, with the val parameter, and bound to the class context

  3. for each key in val (if any!), set instance variables in the instantiated class

So, what does this method do, a part from making my eyes hurt? It loads a yaml file and instantiates a class and sets the ivars found in the yaml file. Sorta.

It is probably the worst code I have ever seen in the ruby standard libs. WTF!!


September 15, 2008
4 thanks

:null => false

To not allow a column to have a NULL value, pass :null => false. Seems silly, but that’s it.

July 28, 2008
2 thanks

":prompt" doesn't work

This does not work:

select :object, :method, options, :prompt =>-select-’

This does work:

select :object, :method, {:include_blank =>-select-’}