コミットログの文字化け対応

  • app/helper/projects_helper.rb
  • app/views/projects/activity.rhtml
  • app/views/repositories/_revisions.rhtml
  • app/views/repositories/revision.rhtml

JSON の変換

# 変換してみる
>> val = val.to_json
  => "[{\"b\": 2, \"c\": 3, \"a\": 1}, {\"d\": 4, \"f\": 6, \"e\": 5}, [11, 12, 13, 14]]"

# 戻してみる
>> ActiveSupport::JSON.decode( val )
  => [{"a"=>1, "b"=>2, "c"=>3}, {"d"=>4, "e"=>5, "f"=>6}, [11, 12, 13, 14]]

Content-Type ヘッダー

class ApplicationController < ActionController::Base
  REGEXP_CONTENT_TYPE = /javascript/
  after_filter :set_charset
  def set_charset
    @headers["Content-Type"] ||= "text/html; charset=utf-8"
    if REGEXP_CONTENT_TYPE =~ @headers["Content-Type"]
      @headers["Content-Type"] = "text/javascript; charset=utf-8"
    end
  end
end

JSON を返す

class HogeController < ApplicationController
  def getHoge
  @product = [
               { :foo => "bar",
                 :hot => "cake",
               }
             ]
  render :json => @product
  end
end

crossdomain.xml を置きたい場合

RAILS_ROOT/public に置けば良い。

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <allow-access-from domain="*" />
</cross-domain-policy>

Create your application skeleton and start the server

$ rails new path/to/your/new/application
$ cd path/to/your/new/application
$ rails server

Installing the Required Gems

$ bundle install

Creating the Database

$ rake db:create

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2011-06-07 (火) 14:19:50 (2812d)