locale_railsの最新は2.0.5。rails2.3.8には対応してない。
でもgithubの先っちょは対応してるのでbundlerの場合はGemfileに下記のように書けばいい。
gem 'locale_rails', '2.0.6', :git => 'git://github.com/mutoh/locale_rails.git'
2.0.6なんて無いのに何故動くんだろう?
vendor/bundle/bundler/gems/locale_rails-xxxxxxxxx-masterの下に入ってるので、submoduleとして扱ってるのかも。gemspecは何処にも無いのでgemを作ってる訳ではなさそう。
普通のRoute
ActionController::Routing::Routes.draw do |map|
map.resources :tasks
end
% rake routes
tasks GET /tasks(.:format) {:action=>"index", :controller=>"tasks"}
POST /tasks(.:format) {:action=>"create", :controller=>"tasks"}
new_task GET /tasks/new(.:format) {:action=>"new", :controller=>"tasks"}
edit_task GET /tasks/:id/edit(.:format) {:action=>"edit", :controller=>"tasks"}
task GET /tasks/:id(.:format) {:action=>"show", :controller=>"tasks"}
PUT /tasks/:id(.:format) {:action=>"update", :controller=>"tasks"}
DELETE /tasks/:id(.:format) {:action=>"destroy", :controller=>"tasks"}
APIの場合、newとeditのページは要らないので絞る。
ActionController::Routing::Routes.draw do |map|
map.resources :tasks, :except => [:new, :edit]
end
% rake routes
tasks GET /tasks(.:format) {:action=>"index", :controller=>"tasks"}
POST /tasks(.:format) {:action=>"create", :controller=>"tasks"}
task GET /tasks/:id(.:format) {:action=>"show", :controller=>"tasks"}
PUT /tasks/:id(.:format) {:action=>"update", :controller=>"tasks"}
DELETE /tasks/:id(.:format) {:action=>"destroy", :controller=>"tasks"}
NESTしたRouteでも絞ろうとすると、
ActionController::Routing::Routes.draw do |map|
map.resources :project, :has_many => :tasks, :except => [:new, :edit]
end
% rake routes
project_tasks GET /project/:project_id/tasks(.:format) {:action=>"index", :controller=>"tasks"}
POST /project/:project_id/tasks(.:format) {:action=>"create", :controller=>"tasks"}
new_project_task GET /project/:project_id/tasks/new(.:format) {:action=>"new", :controller=>"tasks"}
edit_project_task GET /project/:project_id/tasks/:id/edit(.:format) {:action=>"edit", :controller=>"tasks"}
project_task GET /project/:project_id/tasks/:id(.:format) {:action=>"show", :controller=>"tasks"}
PUT /project/:project_id/tasks/:id(.:format) {:action=>"update", :controller=>"tasks"}
DELETE /project/:project_id/tasks/:id(.:format) {:action=>"destroy", :controller=>"tasks"}
project_index GET /project(.:format) {:action=>"index", :controller=>"project"}
POST /project(.:format) {:action=>"create", :controller=>"project"}
project GET /project/:id(.:format) {:action=>"show", :controller=>"project"}
PUT /project/:id(.:format) {:action=>"update", :controller=>"project"}
DELETE /project/:id(.:format) {:action=>"destroy", :controller=>"project"}
projectの方しか絞れない。
こっちの書き方なら両方絞れる。
ActionController::Routing::Routes.draw do |map|
map.resources :projects, :except => [:new, :edit] do |project|
project.resources :tasks, :except => [:new, :edit]
end
end
% rake routes
project_tasks GET /projects/:project_id/tasks(.:format) {:action=>"index", :controller=>"tasks"}
POST /projects/:project_id/tasks(.:format) {:action=>"create", :controller=>"tasks"}
project_task GET /projects/:project_id/tasks/:id(.:format) {:action=>"show", :controller=>"tasks"}
PUT /projects/:project_id/tasks/:id(.:format) {:action=>"update", :controller=>"tasks"}
DELETE /projects/:project_id/tasks/:id(.:format) {:action=>"destroy", :controller=>"tasks"}
projects GET /projects(.:format) {:action=>"index", :controller=>"projects"}
POST /projects(.:format) {:action=>"create", :controller=>"projects"}
project GET /projects/:id(.:format) {:action=>"show", :controller=>"projects"}
PUT /projects/:id(.:format) {:action=>"update", :controller=>"projects"}
DELETE /projects/:id(.:format) {:action=>"destroy", :controller=>"projects"}
スッキリ!
Githubが会社向けに機能充実!・・・と思ったら月100ドルとか意外と高ぇ・・・。
と、思ってたらすぐさまこんなリリースが!
Organizations for Small Businesses - GitHub
Bronzeで月25ドルから。ちょっとこれはいいかもしんないですねー。
リポジトリは開発会社にとって落ちたら業務が出来ないので社内に置くと維持にちょっとドキドキ。社外にサーバー借りるにしても面倒+そこそこ費用がかかる。メンテナンスフリーで使い勝手の良いGithubがこのお値段で使えるならお得じゃないでしょうか。
そうそうそう!
config/routes.rb
ActionController::Routing::Routes.draw do |map|
map.posts 'posts', :controller => 'posts', :action => 'create',
:conditions => {:method => :post}
end
POST
% telnet localhost 3000
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
POST /posts HTTP/1.0
Content-Length: 21
hoge=fuga&hoge2=fuga2
HTTP/1.1 200 OK
Etag: "d1a0c9e0358e819fd093bc7ddd19caeb"
Connection: close
Content-Type: text/html; charset=utf-8
Date: Thu, 01 Jul 2010 08:54:17 GMT
Server: WEBrick/1.3.1 (Ruby/1.8.7/2010-06-23)
X-Runtime: 2
Content-Length: 72
Cache-Control: private, max-age=0, must-revalidate
<h1>Posts#create</h1>
<p>Find me in app/views/posts/create.html.erb</p>
Connection closed by foreign host.
GET
% telnet localhost 3000
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refusedTrying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /posts HTTP/1.0
HTTP/1.1 405 Method Not Allowed
Allow: POST
Connection: close
(以下略)
Module: ActionController::Routing
Route conditions
With conditions you can define restrictions on routes. Currently the only valid condition is :method.
- :method - Allows you to specify which method can access the route. Possible values are :post, :get, :put, :delete and :any. The default value is :any, :any means that any method can access the route.
Introducing Organizations - GitHub
Today we're introducing Organizations. Organizations simplify management of group-owned repositories (for example: your company's code), expand on our permissions system, and help focus your GitHub workflow for business and large open source projects.
githubに会社や大規模オープンソースプロジェクト用のOrganizations機能が入ったそうです。
今までは個人が他人をコラボレーターに追加するしかなかったので大きな会社では使い辛かったかもしれません。Organizations機能でグループ共通のダッシュボードや支払いやユーザー管理も一元化出来るそうです。もう会社でGithub使う準備が出来たって感じですね。
Wifi
$ dmesg | grep Wireless
[ 6.520647] ipw2200: Intel(R) PRO/Wireless 2200/2915 Network Driver, 1.2.2kmprq
[ 6.665137] ipw2200: Detected Intel PRO/Wireless 2915ABG Network Connection
ipw2200ってヤツだそうです。sid main contrib non-freeで下記。
% sudo aptitude install firmware-ipw2x00
配下のディレクトリを755, それ以外を644
% chmod -R 644 .
% find . -type d -exec chmod 755 {} \;
Hoptoadと同種の本番環境でのエラーの内容や回数を管理したり通知してくれるサービス。
ドキュメント通りで何の問題も無く動きます。
% gem install exceptional
require 'rubygems'
require 'sinatra'
set :raise_errors, true
require 'exceptional'
use Rack::Exceptional, API_KEY
get '/' do
"Hello World!"
end
get '/error' do
big.problem!
end
Sinatraでの実際のコードはこんな感じです。
一番の利点はHerokuのAddonからだと月9$が無料になること。しかし、Hoptoadの方がeggプランは元々無料だし、機能豊富なので良い気も。Herokuはなるべくシンプルなサービスを選んで組むそうなのでシンプルな方がよかったのかな。それとも連携に機能的・政治的な問題があったのかな?