2012-12-16 32 views
0

我仔細地計劃了一切並在本地進行了測試,但部署之後可能創建了許多無用的記錄,這些記錄已經在heroku上崩潰了應用程序。Heroku歸還不能批量分配?

我的目標是很多車型合併爲一個主題模式,讓我在Heroku的控制檯用下面的腳本(但應在第一測試了一個記錄):

> Question.find_each do |q| 
* @qt=q.title 
> @qd=q.description 
> @q="Question" 
> @ca=q.created_at 
> @ui=q.user.id 
> @uvt=q.user_votes_total 
> Topic.create!({:title => @qt, :description => [@qd], :kind => @q, :created_at=>@ca, :user_id=>@ui, :user_votes_total=>@uvt }) 
> end 

的Heroku返回此:

Question Load (1.8ms) SELECT "questions".* FROM "questions" WHERE ("questions"."id" >= 0) ORDER BY "questions"."id" ASC LIMIT 1000 
User Load (6.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 3331 ORDER BY users.created_at DESC LIMIT 1 

而且,這DOH !:

WARNING: Can't mass-assign protected attributes: title, description, kind, created_at, user_id, user_votes_total 

我的主題模型是這樣的:

class Topic < ActiveRecord::Base 
    attr_accessible :description, :title, :kind, :user_id, :tag_list, 
       :subject, :image_attributes, :tags_attributes, :created_at, 
       :user_votes_total 
    validates :title, :presence => true, 
       :length => { :minimum => 5 } 
    validates :description, :presence => true 
    validates :kind, :presence => true 
    belongs_to :user 
    has_many :adds 
    default_scope order: 'topics.created_at DESC' 

    votable_by :users 
    acts_as_taggable 

    has_one :image, :as => :parent, :dependent => :destroy 
    accepts_nested_attributes_for :image, :allow_destroy => true 
    after_create do 
    self.create_image unless image 
    end 
    has_many :comments, :as => :commentable, :dependent => :destroy 

    include PgSearch 
    pg_search_scope :search, against: [:title, :description, :kind], 
    using: {tsearch: {dictionary: "english"}} 
end 

我已經搜索了相關信息,但是不知道Heroku爲什麼不玩。有沒有人遇到過這個問題?

+1

道歉,如果這是基本的(但相信我,這在過去已經完成),讓你運行的Heroku運行耙分貝:遷移? – Richlewis

回答