CrossFrameという技術
ドメイン境界を越えてjsで通信する方法。
Introducin
たぶんShootingSt
ドメイン境界を越えてjsで通信する方法。
Introducin
たぶんShootingSt
1 map.resources :users 2 map.resource :session
routes.rbに出てくる、map.resour
map.resour
Creates named routes for implementi
ng verb-orien ted controller s for a singleton resource. A singleton resource is global to the current user visiting the applicatio n, such as a user‘s /account profile.
単数コントローラ名でパスを提供する場合に使えるようです。
- a singular name is given to map.resour
ce. The default controller name is taken from the singular name. - To specify a custom plural name, use the :plural option. There is no :singular option
- No default index, new, or create routes are created for the singleton resource controller
. - When nesting singleton resources, only the singular name is used as the path prefix (example: 'account/me
ssages/1')
ヘルプにある生成されるというパスと私の環境のrake routesで表示されるパスが異なるようなので使用しているrailsで確認することが必要があるように思います。
ので作ってみた。
hash_ext.r
1 class Hash 2 def slice(*args) 3 args = *args if args[0].is_a? Array 4 args.inject({}){|hash, key| hash[key] = self[key]; hash} 5 end 6 end
使い方:
1 conditions= params.slice :year, :month, :day
Rails 2.0(RC1)でチェックしてみたところ、以下のような構文で migration コードの生成時に追加・削除を行うcolumnを指定できるようです。
1 % ./script/generate migration add_fullna me_to_user s fullname:s tring
この結果、生成生成されるコードは以下の通り。
db/migrate
1 class AddFullnameToUsers < ActiveReco rd::Migrat ion 2 def self.up 3 add_column :users, :fullname, :string 4 end 5 6 def self.down 7 remove_col umn :users, :fullname 8 end 9 end
ちょっと前まで、add_xxxx_t で yyyyテーブルにxxxxカラムを
追加するという感じの挙動をしていたのですが、それは無くなったみたいですね。
まだRC1なので最終的にどういう形に落ち着くか分かりませんが、
なかなかいい感じです。