rails

Railsセミナー

今から行ってきます。 月間524万人が利用する食のインフラ、「クックパッド」のものづくり 仕事を早く抜ける口実でもあったりする。

Rails 2.1系でCSRFに関するバグ

By design rails does not perform token verification on requests with certain content types not typically generated by browsers. Unfortunately this list also included ‘text/plain’ which can be generated by browsers. http://weblog.rubyonrail…

Passengerを使ってみた

http://www.modrails.com/ Passengerとはつまるところmod_railsです。暇なので、とりあえず会社のCentOS 5にインストール。 1. Open a terminal,and type: gem install passenger 2. Type: passenger-install-apache2-module And follow the instructions. h…

Railsのシンボル拡張

RailsのActionController::Filters::Filter内に以下のメソッドがあります。 def included_in_action?(controller, options) if options[:only] Array(options[:only]).map(&:to_s).include?(controller.action_name) elsif options[:except] !Array(options[…

attr_internal_accessor

Railsのアクション内で、そういえばrequestやparamsとかってどうやってアクセスしてるのだろうと気になったので調べてみました。とりあえずActionController::Baseを調べてるとassign_shortcuts(request, response)というメソッドを発見。 def assign_shortc…

Viewでコントローラ名とアクション名を取得する

controller.controller_name controller.action_name で取得できる。

rails.vimをインストール

とりあえずSubversionでチェックアウトしてきたら、READMEしか存在せず、中をみるとGITに移動したとのこと。というわけでまずはUbuntuにGITをインストールします。 $ sudo apt-get install git-coreんでrails.vimをインストール。(~/.vim内には各ディレクト…

migration時に自動で外部キーをセットする

Foreign Key Migrations Railsのmigrationって、DBそのものに外部キー制約をつける場合は自前でSQLを書かないといけないので面倒なんですよね。対策の1つとして、以下のようなヘルパを作成する方法があります。 module MigrationHelpers def foreign_key(fro…

t.timestamps

Rails2.0.2でgenerate modelをしたら、t.timestampsっていうのがデフォルトでついてました class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.timestamps end end def self.down drop_table :users end end 大体予想は…