Ruby/Ruby On Rails/Tips のバックアップの現在との差分(No.1)


Ruby On Rails - tips

Ruby On Rails - Tips

Annotate Models Plugin

  • インストール
    script/plugin install http://svn.pragprog.com/Public/plugins/annotate_models

ディレクトリ構成

ディレクトリ名目的
appプログラムを配置
app/controllersコントローラを配置
app/controllers/application.rbアプリケーション共通のフィルタ処理等
app/controllers/xxx.rbコントローラ毎に1ファイル。アクションはファイル内の1メソッド
app/helpersヘルパー:コントローラで共通で使うメソッドを定義
app/helpers/application_helper.rbアプリケーション全体で使うものを配置
app/helpers/xxxx_helper.rbコントローラ毎にも定義できる
app/modelsモデル(含ORMのオブジェクト)を配置、Validateの処理もここに書く
app/viewsビュー(rhtml)を配置、1コントローラに1ディレクトリ、1アクション1ファイル
componentsコンポーネントを配置
config設定ファイルを格納
dbデータベース関係のファイルを配置
docドキュメントを配置
libライブラリを配置
logログファイルを格納
publicWebサーバに対するドキュメントルート
scriptスクリプトファイルを格納
testテスト用のファイルを配置
tmpテンポラリファイルを格納
vendorプラグインファイルを配置
  • 使い方
    rake annotate_models

    これでapp/models以下のファイルに下記のようなコメントをDBから抽出してつけてくれます.
    # Schema as of Mon Feb 27 00:55:58 CST 2006 (schema version 7)
    #
    #  id                  :integer(11)   not null
    #  name                :string(255)
    #  description         :text
    #  image_location      :string(255)
    #  price               :float         default(0.0)
    #  available_at        :datetime
    #
    
    class Product < ActiveRecord::Base
    
      validates_presence_of :name, :description
        . . .

    一応バックアップはとってください.

情報源

DEPRECATION WARNING 対処方法

end_form_tag

1. <%= start_form_tag ... %>
2. ...
3. <%= end_form_tag %> 
↓下記に変更
1. <% form_tag ... do %>
2. ...
3. <% end %>

情報源