:clear_after_save => trueを指定すると、save後はmodified?がtrueじゃなくなる。 person = Person.find(:first) person.age # 100 person.age = 10 person.age_modified? # true person.original_age # 100 person.modified_attributes # {:age => 100} # restore person.restore_attributes :only => :age person.age # 100 # clear person.clear_original_attributes :only => :age # dbと比較 person.modified?(:reload) # true
始めに Windows 環境で Rails 2.2 を使える環境を作ろうとしたところ、MySQL5.1 を使用するとライブラリの関係で正しく動作しないという事象が発生したので、ゼロから環境を構築する手順と合わせてハマり所を記載しておく。 ちなみに、Rails 2.2 であることが原因では無い(ハズ)なので、勘違いしないよう、ご注意ください。 Ruby 環境のインストール Ruby 本体のインストール 上記から Ruby 1.8.7 の mswin 版 zip を取得する。 適当に解凍する(必要があれば適当なディレクトリへ移動しておく) PATH を通す 今回は C:\ 直下に ruby フォルダを作成しておく事にした。追加するPATHは C:\Ruby\bin となる。 さて、PATHが通っているか確認してみよう。 C:\>ruby -v ruby 1.8.7 (2008-08-11 pa
第四十六回 使い方や機能など,詳しくは後で書きます書きました. acts_as_ludiaの更新情報もご覧下さい. acts_as_ludiaの概要と機能 LudiaによるPostgreSQLの高速全文検索機能をRuby on Railsから利用するためのプラグインです.名前はacts_as_ludiaといいます(そのまんまですいません). 今までRailsからLudiaを使う場合,findのconditionsオプションにクエリをごりごり書く必要がありました. Model.find(:all, :conditions => "body @@ '*D+ ruby rails'") これが,acts_as_ludiaを利用すると以下のように簡潔にコードを書くことができます.もちろん,AND/OR検索や日本語での検索も可能です. Model.find_fulltext(:body => "ru
Action Mailer Base Action Mailer allows you to send email from your application using a mailer model and views. Mailer Models To use Action Mailer, you need to create a mailer model. $ bin/rails generate mailer Notifier The generated model inherits from ApplicationMailer which in turn inherits from ActionMailer::Base. A mailer model defines methods used to generate an email message. In these metho
● [Rails][Rails1.1] Reloadable module 実行時にクラスを再読み込みさせるためのモジュールです。include したクラスはアクション実行時に自動的に初期化されます。下記のRails基本クラスのサブクラス群は全て Reloadable 扱いになります。 ActiveRecord::Base ActiveRecord::Observer ActiveController::Base ActionMailer::Base ● メカニズム Dependencies.mechanism = :load である場合(大雑把に言うと development モード)に、dispatcher が該当クラス群を remove_class して、強制的に autoloading を発動させることで実現しています。(賢い!!)。 railties/lib/dispatche
Rails 2.3 delivers a variety of new and improved features, including pervasive Rack integration, refreshed support for Rails Engines, nested transactions for Active Record, dynamic and default scopes, unified rendering, more efficient routing, application templates, and quiet backtraces. This list covers the major upgrades, but doesn't include every little bug fix and change. If you want to see ev
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く