English 中文(简体)
表2
原标题:Table is not being created for some reason

I ran the following commands:

rails generate scaffold order name:string address:text email:string pay_type:string   
rails generate migration add_order_id_to_line_item order_id:integer    
rake db:migrate

由于某种原因, d/sch。 db 斜线显示订单表。 我甚至试图将它人工地置于chem虫中,并再次移徙,但我仍然无法进入/顺序:

没有人会提出什么原因?

Page access errors: https://i.stack.imgur.com/5C3Rm.jpg
Migration outputs: https://i.stack.imgur.com/936k8.jpg

https://github.com/imjp/shop

最佳回答

你的移徙档案20110623001141_combine_items_in_cart.rb没有适当的分类包裹,此外,该档案中还有相应的方法。

class CombineItemsInCart < ActiveRecord::Migration
    def self.up
        # replace multiple items for a single product in a cart with a single item
        Cart.all.each do |cart|
        # count the number of each product in the cart
            sums = cart.line_items.group(:product_id).sum(:quantity)

            sums.each do |product_id, quantity|
                if quantity >1
                    # remove individual items
                    cart.line_items.where(:product_id=>product_id).delete_all

                    # replace with a single item
                    cart.line_items.create(:product_id=>product_id, :quantity=>quantity)
                end
            end
        end
    end

    def self.down
        # split items with quantity>1 into multiple items
        LineItem.where("quantity>1").each do |line_item|
            # add individual items
            line_item.quantity.times do
                LineItem.create :cart_id=>line_item.cart_id,
                                :product_id=>line_item.product_id, :quantity=>1
            end

            # remove original item
            line_item.destroy
        end``
    end
end

您在2011年6月26日203934年1月1日至2007年6月30日期间似乎也有重复。 在2011年6月26日181924年1月1日之前增加一个栏,添加一个栏目,增列一个栏目。 删除一条,再次尝试移民。

问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签