找不到生成器AddListingIdToOrders

时间:2014-03-04 19:53:58

标签: ruby-on-rails ruby

尝试将ID添加到我的订单数据库中 当我在命令行运行迁移时,$ rails生成AddListingIdToOrders listing_id:integer 它给我一个错误找不到生成器AddListingIdToOrders。

cmd neilpatel $ rails生成AddListingIdToOrders listing_id:整数 找不到生成器AddListingIdToOrders。

listing.rb

class Listing < ActiveRecord::Base
    if Rails.env.development?
        has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "photo.jpg"
    else
    has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "photo.jpg",
                      :storage => :dropbox,
                      :dropbox_credentials => Rails.root.join("config/dropbox.yml"),
                      :path => ":style/id_:filename"
    end
    validates :name, :description, :price, presence: true
    validates :price, numericality: { greater_than: 0 }
    validates_attachment_presence :image

    belongs_to :user
    has_many  :orders
end

orders.rb

class Order&lt;的ActiveRecord :: Base的     验证:地址,:city,:state,presence:true

belongs_to :listing

1 个答案:

答案 0 :(得分:1)

您正在寻找的命令是

rails generate migration AddListingIdToOrders listing_id:integer

你错过了'迁移'部分:)