希洛库回来不能大规模分配吗?



我仔细计划了所有内容并在本地进行了测试,但是在部署后可能已经创建了许多无用的记录,这些记录使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  

而且,这个卫生部!

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 不一起玩。有人遇到过这个问题吗?

我能够通过运行来克服这个问题:

`heroku restart`

https://devcenter.heroku.com/articles/ps

最新更新