ActiveSupport

From WhyNotWiki

Jump to: navigation, search

Contents

[edit] "Railisms"

Railisms (core/stdlib extensions in Ruby on Rails) (http://eigenclass.org/hiki.rb?list-of-railisms). Retrieved on 2007-02-02 13:14.

If you've ever written a piece of code that worked fine in a Rails app but bombed elsewhere, you've probably been relying on a Railism unknowingly.

I used rcodetools' rct-meth-args to generate a list of Railisms (extensions to the core/stdlib classes), by processing an intermediate tags file*1.

The list is fairly comprehensive, since it takes into account included and extended classes/modules in addition to class-reopening. It also includes information about the method arguments (names and default values), as returned by rct-meth-args.

There are over 220 Railisms. You can find the full list (corresponding to activesupport-1.4.0) below.

...

[edit] with_options

http://weblog.jamisbuck.org/2007/1/22/named-explicit-routes

It just lets you specify common options and then yield to a block. The block recieves a proxy object, which passes all methods through to the original receiver, and merges the options into any option hashes.

map.connect "/people", :controller => "people", :action => "index"
map.connect "/people/:id", :controller => "people", :action => "show"

# is the same as this:
map.with_options :controller => "people" do |people|
  people.people "/people",     :action => "index"
  people.person "/people/:id", :action => "show"
end



[edit] blank?

Defined in /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/blank.rb

"", " ", nil, [], and {} are blank

[edit] Can/should ActiveSupport be used outside of Rails apps?

It's probably best not to use it. It's pretty big and has more than you probably need.

Plus I've had problems with it, when I was trying to use it in order to get mattr_accessor. I ended up just copying the file containing that method and pasting it into my project. (I know, that was very bad of me.)

In the case of mattr_accessor and many other methods in fact, you can find identical copies of those methods in the Facets library! So it would be preferable to use them instead -- because Facets lets you just include those files/methods that you want.


[edit] Article metadata

Article Metadata:

Convention/template/schema:

For each method mentioned here, have a column "Facets equivalent" which has a link to the equivalent method in Facets if it exists. And any notes about incompatibility, or when it was copied over, or in which direction the copying happened.

Aliases: Railisms


ActiveSupport  edit   (Category  edit)

Personal tools