You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
Migrationとは Migration とは、Railsで使うデータベースの管理機能で、テーブル作成・カラ ムの追加/変更などの作業を一元管理できます。SQL でスキーマを書くのでは なく、Rails独自の記法(Rubyの文法の範囲内)を使ってDB管理を行います。以 下のようなメリットがあります。 スキーマのバージョン管理ができる rake コマンドでスキーマのバージョンアップ/ロールバックが可能 データベースに依存しない書き方ができるので、他のデータベースに切り替えるのが容易 対応しているデータベース 現在、対応しているデータベースは MySQL, PostgreSQL, SQLite, SQL Server, Oracle です。 今後、対応DBは増えていくと思います。最新情報は、 http://api.rubyonrails.org/classes/ActiveRecord/Mi
Rails model files contain no information on the tables they represent. This is a good thing in general, because it reduces duplication—add a column to a table, and there’s no configuration to update in the model. However, when you’re writing code, it’s sometimes nice to be able to see just what attributes a model has. Enter annotate models, a really trivial Rails plugin I hacked up in the plane ba
下記のようなに,抽象モデルを上位に作り,それを継承する感じにする. class Human < ActiveRecord::Base self.abstract_class = true class << self def find(*params) puts "before_find" super end end end class Person < Human end すると, >> Person.find(:all) before_find => [#<Person id: 1.... などとなる.データベース実体のない抽象モデルを作ることで,ActiveRecordに手を加えなくともテーブル分割や分散データベース処理などできそうです.
先日の金曜日に、社内でnamed_scopeの勉強会をやりました。 RubyKaigiで松田さんがしゃべった話がたいそう面白かったので、実際にnamed_scopeの実装を見てみよう、というテーマです。 | View | Upload your own 調べて改めて思ったんですが、これはまたよくできてますね。 method_missingを活用しまくっているという意味ではいつもの「イヤな予感」がするんですが、使い方がキレイで脱帽です。このあたりの「味わい」はスライド後半のコールシーケンスをご覧ください。複雑なことをやっているんですが、一度わかるとものすごく腑に落ちる感じが、何ともうまいですよね。うん。 今回取り上げたのはリリース版(AR2.1)のnamed_scopeですが、現時点でもいろんな機能が追加されてますのでまた先々も楽しみです。Railsレシピブックも改版する機会があったら(今回
Active Record Cluster ttp://rakuto.nobody.jp/src/active_record_cluster.zip 直接リンクだと403になります。 右クリックでURLをコピーして直接URLバーに入力してください。 を作りました。 で、これは何かって言うと DBコネクションをクラスタ単位で扱うためのプラグイン。 「DB一台じゃクエリ捌くの無理だろ」って時に使います。 だけど、ActiveRecordは複数DBを扱うのに向いていないんですよ。 というかRails作者のDavid自身が一つのDBでARを使うことを強くお勧めしています。 そのため内部では、クラス名をハッシュキーとスレッドIDをキーとしてコネクションアダプタ(ActiveRecord::ConnectionAdapter)をキャッシュしています。 ActiveRecord Clusterでは、クラ
Introduction ActsAsReadonlyable adds support of multiple read-only slave databases to ActiveRecord models. When a model is marked with acts_as_readonlyable, some of AR finders are overridden to run against a slave DB. The supported finders are find, find_by_sql, count_by_sql, find_[all_]by_*, and reload. Finders can be forced to fall back to a default DB by passing the :readonly flag set to false.
→ Ruby on Rails → ActiveRecords WARNING Despite the 1.0.0 version number, various people have experienced problems using this tool. I haven’t yet found a solution (I haven’t really been looking though), so please subscribe to the forum or RubyForge news for any updates on a solution. What ActiveRecord models are allowed one connection to a database at a time, per class. Ruby on Rails sets up the d
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く