3

Railsのドキュメントには、次の例があります。

class Physician < ActiveRecord::Base
  has_many :appointments
  has_many :patients, :through => :appointments
end

私はちょうど興味があります: コマンドラインを使用してこれを生成することは可能rails generate modelですか?

4

1 に答える 1

4

から取得した使用法メッセージによるとは限りませんrails generate modelbelongs_toただし、関係を設定することはできます。

rails generate model photo title:string album:references

で次のことを教えてくれますapp/models/photo.rb:

class Photo < ActiveRecord::Base
  belongs_to :album
end
于 2012-11-19T21:05:04.837 に答える