今日のハマリ。

TwitterAuth::Dispatcher::Error (Status is a duplicate.):
  oauth (0.3.5) lib/oauth/tokens/access_token.rb:44:in `post'
  app/controllers/votes_controller.rb:25:in `tweet'

Tweet部分でエラーが返る。自分のアプリのせいだと思い込んでいたんですが、statusって何だ?ステータスってものは人に一つじゃないの?何でステータスがduplicateするんだ?

冷静に考えたらTweetは元々、メッセンジャーなどで使う「komagata@仕事中」の右の部分。それの遷移を時間軸で蓄積したものがタイムラインなのでつぶやきの公式な名前はpostでもtweetでも無くstatusだ。

同じ時間帯に全く同じstatusを送ったので「Status is a duplicate.」という訳でした。

次のソース: http://help-me-hackers-production/

railsのproductionでhamlのインデントが効いてない?

File: HAML_CHANGELOG

2.2.0

New Options

:ugly

The :ugly option is not technically new; it was introduced in Haml 2.0 to make rendering deeply nested templates less painful. However, it’s been greatly empowered in Haml 2.2. It now does all sorts of performance optimizations that couldn’t be done before, and its use increases Haml’s performance dramatically. It’s enabled by default in production in Rails, and it’s highly recommended for production environments in other frameworks.

新しいSyntaxが加わった2.2.0から深いネストが遅くなったのでproductionではデフォルトで:uglyオプション有効でインデント無しだそうです。

・・・・・・・・・。

こんな多数派の迫害にもう我慢ならないっ!

少数派の諸君!今すぐ下記のように:uglyオプションをぶち壊して政府転覆の恐ろしい計画を練ろうじゃないか!

# config/initializers/haml.rb
Haml::Template::options[:ugly] = false

何だかんだ言ってもdevelopmentとproductionで挙動の違いの問題は出る。

# /etc/hosts
127.0.0.1 foo foo-production
<VirtualHost *:80>
ServerName foo
DocumentRoot "/Users/komagata/Sites/foo/public"
RailsEnv development
</VirtualHost>

<VirtualHost *:80>
ServerName foo-production
DocumentRoot "/Users/komagata/Sites/foo/public"
</VirtualHost>

こうしておくと便利。

直読み(いつも忘れる・・・)

<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

実際には大した種類のルーティングは無いのでデフォルトのルーティングは外しといた方がトラブルが少ない。(無名のルートは持たないように気を付ける感じ?)

ActionController::Routing::Routes.draw do |map|
#  map.connect ':controller/:action/:id'
#  map.connect ':controller/:action/:id.:format'
end

/index.htmlも設定しとかないとYahooにインデクスされない。

ActionController::Routing::Routes.draw do |map|
  map.root :controller => 'top'
  map.root_for_yahoo 'index.html', :controller => 'top'
end

持ってることすら忘れてたPSPを発掘。

初めて知ったんですが、昔のゲームとかがPSPだけでダウンロード購入できるんですね。昔のゲーム(といっても初代PSのゲームとかですが)の方が最近の難しいやつよりなじみやすく、わざわざ買いに行くのも億劫なおっさんにはちょうどいい感じです。値段も300円や600円が主で、Amazonで数千円の本をポコポコ買ってるのに比べれば大分安いですね。

PSPの無線LANはWPA2には対応してなかったのでワザワザ自宅のアクセスポイントをWPAに弱めて接続しました・・・。

最近ニコニコ動画でプレイ動画や実況を見ていてた、「クーロンズゲート」や「俺の屍を越えてゆけ」も600円と安いのでちょっと気になります。買ってみようかな~。

ARTDINK BEST CHOICE クーロンズ・ゲート-九龍風水傅-
俺の屍を越えてゆけ PlayStation the Best
class Tag < ActiveRecord::Base
validates_format_of :name, :with => /^\S+$/
validates_uniqueness_of :name, :case_sensitive => false

def before_validation
self.name.downcase!
end
end

小文字のみ、空白とか禁止。acts_as_taggableなんちゃら系なら多分共通。

これ危険!productionではmodelの読み込み順が違うのでエラー!とりあえず、pluginを直接書き換えて対応中・・・。

cucumberがtwitter-authの中でコケる。
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[] (NoMethodError)
/Users/komagata/Sites/help-me-hackers/vendor/plugins/twitter-auth/lib/twitter_auth.rb:42:in `strategy'
/Users/komagata/Sites/help-me-hackers/vendor/plugins/twitter-auth/lib/twitter_auth.rb:50:in `oauth?'
/Users/komagata/Sites/help-me-hackers/vendor/plugins/twitter-auth/app/models/twitter_auth/generic_user.rb:69

modelだけ簡単なのでrspecで書いて、他をcucumberと思いきやoauthでコケるのでテストが後回しになってしまうといていたらく・・・

みなさんoauthはどうやってテストしてます?

現在開発中のWebサービス、Help me, hackers! のソースコードを公開しました。

WikiBTSリポジトリもgithubのこのPublicなとこで進めて行きます。

http://github.com/komagata/help-me-hackers

サービス開始前からソース公開というのは正気の沙汰じゃない気もしますが、Webサービスのクローンソフトが本家に悪影響を与えたという話しも聞かないし、対象ユーザーがプログラマーということもあって、良い事の方が多い気がするので実験です。

生放送で作ってる時点で、非公開のモノがあるとやり辛いんですよね。公開後はそこでこのサービス自体の開発のタスク(BTSのIssue)を依頼して行きたいと思います。