タグ

関連タグで絞り込む (2)

タグの絞り込みを解除

ActiveRecordに関するteengenerateのブックマーク (3)

  • has_many :through : How do you access join table attributes?

    I have the following models in Rails 4 with a simple has_many :through association: class Model < ActiveRecord::Base has_many :model_options has_many :options, through: :model_options end class Option < ActiveRecord::Base has_many :model_options has_many :models, through: :model_options end class ModelOption < ActiveRecord::Base belongs_to :model belongs_to :option end I want to be able to iterate

    has_many :through : How do you access join table attributes?
  • ruby/rails/RailsGuidesをゆっくり和訳してみたよ/Active Record Associations - 株式会社ウサギィwiki

    Active Record アソシエーションのガイド(A Guide to Active Record Associations) † このガイドでは、 Active Record アソシエーション機能を説明します。 このガイドを参照することで、以下のことができるようになります: Active Record のモデル間のアソシエーションの宣言 Active Record アソシエーションの様々な種類への理解 アソシエーションの作成によってモデルに追加されるメソッドの利用 ↑ 1 何故アソシエーションなの?(Why Associations?) † 何故モデル間にアソシエーションが必要なのでしょう? それは、コード内の一般的な操作を単純で簡単にするからです。 例えば、 顧客のためのモデルと注文のためのモデルが含まれている簡単なRailsアプリケーションを考えて下さい。 各顧客は、多く

  • ActiveRecordの関連のすべて ー StoneDot の Ruby on Rails 講座

    今回は ActiveRecord ついて説明していきたいと思います。 A Guide to Active Record Associationsと、 Active Record Query Interface を参考にしました。 また、図もこちらから拝借させていただきました。 Rails での関連 Rails では関連を設定することでモデルオブジェクトを接続し構造を作ることが出来ます。 関連の設定はモデルクラスに宣言的にメソッドを書き入れることによって行います。 使えるメソッドとしては大きく分けて以下の6種類があります。 belongs_to has_one has_many has_many :through has_one :through has_and_belongs_to_many ここからはこれらのメソッドをどのように使うのかを説明していきたいと思います。 一対一関連 一対一関

    ActiveRecordの関連のすべて ー StoneDot の Ruby on Rails 講座
  • 1