Dismiss Join GitHub today GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together. Sign up
Why? I hate SQL fragments in Rails code. Resorting to where('name LIKE ?', '%something%') is an admission of defeat. It says, “I concede to allow your rigid, 1970′s-era syntax into my elegant Ruby world of object oriented goodness.” While sometimes such concessions are necessary, they should always be a last resort, because once you move away from an abstract representation of your intended query,
This guide covers different ways to retrieve data from the database using Active Record. After reading this guide, you will know: How to find records using a variety of methods and conditions. How to specify the order, retrieved attributes, grouping, and other properties of the found records. How to use eager loading to reduce the number of database queries needed for data retrieval. How to use dy
ActiveRecord.js makes it easy to begin working with databases in JavaScript on the client or server, with Aptana Jaxer, Google Gears & Chrome, Adobe AIR or any platform supporting the W3C HTML5 SQL Specification (currently Webkit and iPhone). Project Features ActiveRecord.js is a single file, relies on no external JavaScript libraries, supports automatic table creation, data validation, data synch
ar-extensions 0.8.0 is finally released! All known bugs and compatibility issues with Rails 2.1.0 have been resolved. 0.8.0 does not work with the latest Rails edge due to some additional features on edge that weren’t in 2.1.0 0.8.0 should not be used with Rails 2.0.2 or below If any feature requests or bugs please report them on lighthouse Installing Oracle and PostgreSQL users If you’re using ar
突然の出会い: プラウベルマキナについて 日本がバブル経済に突き進み始めた頃に3,500台ほど作られ、数年後にひっそり生産が閉じられた超短命製品プラウベルマキナW67とご縁があった。 その生産数の少なさからまともな個体と出会うことがなかったのだけど、使わないデジタル機材一式を売りに行った帰りにガラス…
Rails2.0でscaffoldを行うと、HTMLと同じURL+.xmlでXMLの取得も行えます。リソースひとつだけ取得するのであればこのままでも大丈夫なのですが、たとえばuserとblogが1:nの関係で、userのXMLを取得する時に同時に複数のblogも取得したい場合どのようにすればよいのかわかりませんでした。 to_xmlを使わずテンプレートでがんばろうかなと思っていたところ、1年前のRyan’s Scrapsでまさにそのものな:includeオプションを見つけました。 @user = User.find(1) @out = @user.to_xml(:include => :blogs) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @out } end <?xml
Get the power of ActiveRecord models, including validation, without having a table in the database. class Contact < ActiveRecord::BaseWithoutTable column :name, :string column :email_address, :string column :message, :text validates_presence_of :name, :email_address, :string end This model can be used just like a regular model based on a table, except it will never be saved to the database. Name U
はてなグループの終了日を2020年1月31日(金)に決定しました 以下のエントリの通り、今年末を目処にはてなグループを終了予定である旨をお知らせしておりました。 2019年末を目処に、はてなグループの提供を終了する予定です - はてなグループ日記 このたび、正式に終了日を決定いたしましたので、以下の通りご確認ください。 終了日: 2020年1月31日(金) エクスポート希望申請期限:2020年1月31日(金) 終了日以降は、はてなグループの閲覧および投稿は行えません。日記のエクスポートが必要な方は以下の記事にしたがって手続きをしてください。 はてなグループに投稿された日記データのエクスポートについて - はてなグループ日記 ご利用のみなさまにはご迷惑をおかけいたしますが、どうぞよろしくお願いいたします。 2020-06-25 追記 はてなグループ日記のエクスポートデータは2020年2月28
最近、2.0な方々の間でTwitterが話題になってる。で、そのTwitter自体も面白いんだけど、TwitterについてDHHがブログを書いてRailsでの大規模サイト構築が話題になってるのが面白い。 Twitter trouble (Loud Thinking - DHH) まずTwitterの高負荷について言及、Twitterは11,000リクエスト/秒 の高負荷で問題となっているらしい。 そしてスケーラビリティの鍵はDB分割だ、と言っている。Railsは基本一つのDBを見るのでスケーラビリティの問題になる (確かにWebサーバはロードバランサがあればいくらでもスケールするしね、Sessionの共有だけ気を付ければ) ↓ Dr Nic » Magic Multi-Connections: A “facility in Rails to talk to more than o
久々に面白いモノを作った。 SlowQueryLogger RailsではActiveRecordを利用してガンガン富豪プログラムを書きがちなため、適切にインデクスを張っていないとすぐに重たくなるので、Rails中で発行された遅いクエリをロギングするプログラムを作った。 ActiveRecordの参照系クエリを発行するメソッドをEXPLAINにより実行解析情報を取得しロギングしてから通常の参照クエリを発行するように拡張し、Rails付属のUnit::TestのfunctionalテストまたはRSpecのコントローラーのSpecファイルを実行する。最終的には、filesortか一時テーブルを使用しているクエリがログファイルに書き出される。 つまり、functional testを定義したファイルかRSpecのcontrollerのスペックファイルがあれば特に何も用意する必要はない。 現在My
→ 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
WillPaginate Pagination is just limiting the number of records displayed. Why should you let it get in your way while developing, then? This plugin makes magic happen. Did you ever want to be able to do just this on a model: Post.paginate :page => 1, :order => 'created_at DESC' … and then render the page links with a single view helper? Well, now you can. Some resources to get you started: Your mi
An easier way to create where clauses. Creates a class for easily building the where clauses for the Model.find(…, :conditions => condition ) c = InVisible::Cond.new do first "Jens-Christian" last "Fischer" age '>', 30 city 'like', 'Zur%' Adress.find( :all, :condition => c.where ) or Adress.find_with_conditions( :all ) do first “Jens-Christian” last “Fischer” age ‘>’, 30 city ‘like’, ‘Zur%’
This is a little tune I’ve been humming a lot lately. It’s as handy as array.map(&:property). Really. You ever find yourself doing something like this? def change_state(object_id, new_state) object = find(object_id) object.state = new_state object.save object end Maybe not, but the pattern’s there: make an object, do something to the object, return the object. Rails’ returning method bundles this
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く