RubyGems の設定ファイル
オプションのデフォルトを設定するには、~/.gemrc か /etc/gemrc を作成する
$ gem help environment (省略) Command line argument defaults and some RubyGems defaults can be set in ~/.gemrc file for individual users and a /etc/gemrc for all users. A gemrc is a YAML file with the following YAML keys: :sources: A YAML array of remote gem repositories to install gems from :verbose: Verbosity of the gem command. false, true, and :really are the levels :update_sources: Enable/disable automatic updating of repository metadata :backtrace: Print backtrace when RubyGems encounters an error :bulk_threshold: Switch to a bulk update when this many sources are out of date (legacy setting) :gempath: The paths in which to look for gems gem_command: A string containing arguments for the specified gem command Example: :verbose: false install: --no-wrappers update: --no-wrappers (省略)
$ less ~/.gemrc :sources: - http://gems.rubyforge.org/ - http://gems.github.com/ install: --no-rdoc --no-ri update: --no-rdoc --no-ri
coLinuxのインストール
coLinux | 0.7.3 |
ディスクイメージ | Debian 4.0 Etch |
OS | Windows XP Home Edition SP3 |
ネットワーク | ワイヤレス ネットワーク |
ネットワークの設定
ファイル共有
EZ-NET: 起動時に SMB ボリュームをマウントする の 起動時にマウントさせる
NetBeans 6.5.1用のパッチ
Rails 2.3.2 で Mongrel や WEBrick をサーバーとして使用するとその起動が NetBeans から認識できず、ブライザが起動しなかったり、すでに起動してあるブラウザの場合はページを更新できないという問題があります。
http://blogs.sun.com/NetBeansSupport_ja/entry/netbeans_rails_2_3_2
…
担当の Mononen が NetBeans 6.5.1 用のパッチ (jar ファイル)を提供してくれています。必要な方は jar ファイルを NetBeans にインストールしてあるものと置き換えて使ってみてください。
Polymorphic Association
class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true end class Article < ActiveRecord::Base has_many :comments, :as => :commentable end class Photo < ActiveRecord::Base has_many :comments, :as => :commentable #... end
Rails 2.3 : Nested Attributes / Nested Object Forms
accepts_nested_attributes_for / fields_for
Nested attributes allow you to save attributes on associated records through the parent.
automatic (and atomic) saving of a record together with its associated children, child-aware validations, and support for nested forms.
class Customer < ActiveRecord::Base has_many :orders accepts_nested_attributes_for :orders, :allow_destroy => true end
<% form_for @customer do |customer_form| %> <%= customer_form.text_field :name %> <% customer_form.fields_for :orders do |order_form| %> <%= order_form.text_field :number %> <% unless order_form.object.new_record? %> <%= order_form.check_box :_delete %> <% end %> <% end %> <%= customer_form.submit %> <% end %>
Ruby on Rails 2.3 Release Notes - 4.1 Nested Attributes
Ruby on Rails 2.3 Release Notes - 6.1 Nested Object Forms
Module: ActiveRecord::NestedAttributes::ClassMethods
Module: ActionView::Helpers::FormHelper
Nested AttributesとNested Model Formsを使って親子オブジェクトを一括で登録/変更するには
Rails 2.3 : Nested Transactions
transaction(:requires_new => true)
If you want a transaction to be nested, you must explicitly add the :requires_new option.
User.transaction do User.create(:username => 'Admin') User.transaction(:requires_new => true) do User.create(:username => 'Regular') raise ActiveRecord::Rollback end end User.find(:all) # => Returns only Admin
Ruby on Rails 2.3 Release Notes - 4.2 Nested Transactions
Module: ActiveRecord::Transactions::ClassMethods