tips

title を動的に設定する

<title><%= content_for?(:title) ? yield(:title) : "default title" %></title> <% content_for :title do %> <%= post.user.name %>'s post <% end %> その他、参考 ActionView::Helpers::CaptureHelper#content_for ActionView::Helpers::CaptureHelper#content_for?

指定した長さの文字列を生成する

10.times.inject("") {|str| str << "a" }.size # 10 "".center(10, "a").size # 10 ("a" * 10).size # 10

homebrew でインストールオプションを表示する

% brew options formula% brew options ruby ruby --with-suffix Add a 19 suffix to commands --with-doc Install with the Ruby documentation --universal Compile a universal binary (arch=x86_64,i386)

git で編集したファイルを元に戻す

git checkout -- <file></file>