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
Active Record Active Record objects don’t specify their attributes directly, but rather infer them from the table definition with which they’re linked. Adding, removing, and changing attributes and their type is done directly in the database. Any change is instantly reflected in the Active Record objects. The mapping that binds a given Active Record class to a certain database table will happen au
I'm writing a Rails 3 ActiveRecord query using the "where" syntax, that uses both the SQL IN and the SQL OR operator and can't figure out how to use both of them together. This code works (in my User model): Question.where(:user_id => self.friends.ids) #note: self.friends.ids returns an array of integers but this code Question.where(:user_id => self.friends.ids OR :target => self.friends.usernames
はじめに 第3回の今回は、正規化された「テーブル」と、人間にとって分かりやすい「画面」。このギャップを超えるための中間層について解説します。 Railsによる開発では、テーブルの構造に従って、入力項目や画面遷移といったインタフェースの仕様が決まります。具体的には、あるテーブルの名前が確定すると、それに沿ってモデルやコントローラの名前が決まり、テーブルの属性によって、画面の入出力項目が決まります。さらに、モデルの関連や振る舞いに従って、定義するアクション、画面遷移、ルーティングが決まります。 この様子を、次の図1に示します。 このように、テーブル構造とインタフェースを直結してサクサクとアプリケーションを作成していくのが、Rails開発の面白さです。 しかし、よく考えてみると、「テーブル」とは、正規化された、いわば「コンピュータにとって分かりやすい」構造です。そのままだと、使いづらいアプリケー
In rails 3.0.0, the following query works fine: Author.where("name LIKE :input",{:input => "#{params[:q]}%"}).includes(:books).order('created_at') However, when I input as search string (so containing a double colon followed by a dot): aa:.bb I get the following exception: ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: created_at In the logs the these are the sql que
Rails3 では ActiveRecord の部分で Arel という関係代数モデルのモジュールが使われるということなので少しだけ予習しておく。 CREATE TABLE articles ( id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, title TEXT, body TEXT, author TEXT, create_date TIMESTAMP, update_date TIMESTAMP ); CREATE TABLE comments ( id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, parent_id INTEGER NOT NULL, title TEXT, author TEXT, mail TEXT, url TEXT, body TEXT, create_date T
Active Recordクエリのインターフェイス(Active Record Query Interface) † このガイドでは、Active Recordを使用してデータベースからデータを取得するためのさまざまな方法を網羅します。 このガイドを参照することで、以下のことが出来るようになります: 様々なメソッドや制約を使ってレコードの探索。 順序、取得属性、グルーピング、見つかったレコードの他のプロパティの指定。 データ検索のために必要なデータベースのクエリの数を減らすためにeager loadingの使用。 動的なファインダメソッドの使用。 カスタム検索の動作をモデルに追加するために名前付きスコープの作成。 特定のレコードの存在のチェック Active Recordモデル上の様々な計算の実行 データベースのレコードを検索するために生のSQLを使用して使用している場合、 一般的に
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く