Agile Web Development with Rails, Third Edition

Jan 发表于 2008-04-24 09:32:10

by Sam Ruby, Dave Thomas, David Heinemeier Hansson, et al

Updated for Rails 2

http://www.pragprog.com/titles/rails3/agile-web-development-with-rails-third-edition
关键词(Tag): rails agile
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

habtm and has_many :through

Jan 发表于 2008-04-23 17:26:15

Most articles on the web give ppl an impression that habtm(has_and_belongs_to_many) is outdated and you should use has_many :through in many-to-many relationship between ActiveRecord models. I'd say that's wrong.

In fact habtm is more closer to has_many without :through than has_many :through, like it will add #{collection}_ids method but has_many :through won't. And habtm is NOT outdated, has_many :through is not a replacement of habtm. You should restrict yourself to use has_many :through only when you have to model the join table in the middle, in any other case, habtm is the better choice.
关键词(Tag): through habtm has_many
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

[Announce] ActsAsOptions

Jan 发表于 2008-04-17 15:43:11

ActsAsOptions
=============

This plugin make model acts like select options

Installation
------------

In your rails directory:

script/plugin install http://janx.googlecode.com/svn/trunk/acts_as_options

How To Use
----------

After installed, add the 'acts_as_options' line to your model:

class Brand
  acts_as_options
end

By default ActsAsOptions suppose you have a 'name' column and a 'id' column in your table, you can change this of course(see below).

After the declaration whenever you need options for a select in form, simply:

f.select :brands, Brand.find_as_options
or
select_tag :brands, Brand.find_as_options

you can specify the name and value column when declaration or find:

acts_as_options :stub, :id # will generate <option value='<%= brand.id %>'><%= brand.stub %></option>
Brand.find_as_options :stub, :id
关键词(Tag): plugin rails
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

[Announce] urlview.rb

Jan 发表于 2008-04-15 21:05:43

I'm glad to annouce the new boring/repetitititititititititititive tool: urlview.rb. It will help u to extract urls out from a paragraph and provides a very light curses based UI for u to open the url in your favorate browser. You can try it like this:

./urlview.rb urlview.rb
or
cat urlview.rb | urlview.rb

I hope it will be loved by the ppl who is both a rubist and mutt user :-)  When use with mutt like this u can use C-b to open links in mail:

macro pager \cb <pipe-entry>'<PATH TO URLVIEW.RB>'<enter> 'Follow links with urlview'

enjoy.
关键词(Tag): ruby urlview mutt
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

wmii dev version + ruby-wmii : resize/WMII_ADDRESS/etc.

Jan 发表于 2008-04-06 22:01:45

wmii is cool since it's configurable with *ANY* language. As a rubist I use ruby-wmii by Mauricio (who is well known as mfp).

One problem is you can't assign shortcuts to resize a window in the latest wmii release. I asked for this in wmii's mailing list and luckily Kris, the author of wmii, quickly replied and implemented this. It's great, but the new problem is I found that WMII_ADDRESS, a environment variable, which will be set when wmii start in latestest stable release, does no longer exist in development version. And ruby-wmii will ask for it when wmii starts, so in one sentence, wmii version 'hg2307+' won't work with ruby-wmii.

Have no time to dig more, just create a quick patch to fix this:

around line#96 In cmd/wmii/main.c

Original:

    if(address)
        setenv("WMII_ADDRESS", address, true);
    else
        address = smprint("unix!%s/wmii", ns_path);

To:

    if(!address)
        address = smprint("unix!%s/wmii", ns_path);

    setenv("WMII_ADDRESS", address, true);

May post a better solution later.
关键词(Tag): window wmii resize wmii_address
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

UTF8 and MPD

Jan 发表于 2008-04-05 14:23:20

To make chinese songs shows correctly in mpd, add these two lines in your mpd.conf

filesystem_charset              "UTF8"
id3v1_encoding                  "UTF8"

Now you should be able to see familiar characters in Sonata. Further, if you want chinese work in ncmpc, try this:

sudo cp /usr/lib/libncursesw.so.5.6 /usr/lib/libncurses.so.5.6

* Your terminal should be configured correctly to display chinese characters
关键词(Tag): utf8 mpd ncmpc
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

谷歌人肉

Jan 发表于 2008-04-01 14:31:52

http://www.google.cn/intl/zh-CN/renrou/index.html

ps. Today is April 1st
ps2. SeSe
关键词(Tag): google april
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

Cap a Cap, 我赞美你

Jan 发表于 2008-04-01 14:09:29

a.t.t.
关键词(Tag): capistrano
收藏: QQ书签 del.icio.us 订阅: Google 抓虾