ドメイン境界を越えてjsで通信する方法。

Introducing CrossFrame, a Safe Communication Mechanism Across Documents and Across Domains

たぶんShootingStarで使ってる方法と同じものだと思う。

posted by Png genki on Wed 28 Nov 2007 at 16:11

   1    map.resources :users
   2    map.resource :session

routes.rbに出てくる、map.resource。綴り間違い??とひそかに思っていたらちゃんとありました。
map.resourceについてヘルプを見てみます。

Creates named routes for implementing verb-oriented controllers for a singleton resource. A singleton resource is global to the current user visiting the application, such as a user‘s /account profile.

単数コントローラ名でパスを提供する場合に使えるようです。

  • a singular name is given to map.resource. 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/messages/1')
  • 単数形を使ったリソースを提供できます
  • :pluralオプションを使えば、複数を使うこともOK。:singularオプションはありません。
  • index, new, createのroutesは作られません
  • 入れ子で単数形resourceを使っている場合、prefixには単数形が使われます
    ex 'account/messages/1'

ヘルプにある生成されるというパスと私の環境のrake routesで表示されるパスが異なるようなので使用しているrailsで確認することが必要があるように思います。

posted by Png satoko on Wed 28 Nov 2007 at 05:51

ので作ってみた。

hash_ext.rb

   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

posted by Png genki on Wed 28 Nov 2007 at 04:16

Rails 2.0(RC1)でチェックしてみたところ、以下のような構文で migration コードの生成時に追加・削除を行うcolumnを指定できるようです。

   1  % ./script/generate migration add_fullname_to_users fullname:string

この結果、生成生成されるコードは以下の通り。

db/migrate/XXX_add_fullname_to_users.rb

   1  class AddFullnameToUsers < ActiveRecord::Migration
   2    def self.up
   3      add_column :users, :fullname, :string
   4    end
   5  
   6    def self.down
   7      remove_column :users, :fullname
   8    end
   9  end

ちょっと前まで、add_xxxx_to_yyyy で yyyyテーブルにxxxxカラムを 追加するという感じの挙動をしていたのですが、それは無くなったみたいですね。 まだRC1なので最終的にどういう形に落ち着くか分かりませんが、 なかなかいい感じです。

posted by Png genki on Wed 28 Nov 2007 at 02:07

そうじゃないか。

posted by Png genki on Tue 27 Nov 2007 at 09:05
Contents
CrossFrameという技術
map.resourcesとmap.resourceの違い
Hash#sliceが欲しい
migrationコードの生成時に変更するcolumnを指定する
十分に魅力的なプロジェクトに締め切りは必要ない
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ