Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在heroku上的rails中充当类的实例_Ruby On Rails_Ruby_Ruby On Rails 3_Ruby On Rails 3.1_Heroku - Fatal编程技术网

Ruby on rails 在heroku上的rails中充当类的实例

Ruby on rails 在heroku上的rails中充当类的实例,ruby-on-rails,ruby,ruby-on-rails-3,ruby-on-rails-3.1,heroku,Ruby On Rails,Ruby,Ruby On Rails 3,Ruby On Rails 3.1,Heroku,创建新帐户时,我有类似于以下的代码作为创建后回调: def after_account_create new_account = self logger.info( '%%%%%%%%%%%%%%%%%%%%% account is = ' + new_account.inspect) assessment = Assessment.new :title => "Cake baking", :description => "Every day

创建新帐户时,我有类似于以下的代码作为创建后回调:

def after_account_create
  new_account = self
  logger.info( '%%%%%%%%%%%%%%%%%%%%%     account is = ' + new_account.inspect)          
  assessment = Assessment.new :title => "Cake baking", :description => "Every day we bake fresh cakes to sell in our shop. This is our assessment of the risks involved in this process.", :account_id => new_account.id
  assessment.save!
end
当我在我的开发环境(乘客/博士后)上运行此功能时,它运行良好-每次个人注册并创建新帐户时,它都会创建一个分配给该个人帐户的新评估

但是,当我在我的生产环境(Heroku上的瘦Web服务器)上运行此操作时,每次有个人注册并创建一个新帐户时,它都会创建一个新的评估,但分配给前一个人的帐户

以下是第二个人创建帐户时两个日志中的示例:

发展

%%%%%%%%%%%%%%%%%%%%%     account is = #<Account id: 97, name: "Eric Clapton", plan: "Partnership", billing_zip: nil, no_of_users: 1, no_of_assessments: nil, id_of_admin_user: 90, created_at: "2012-04-05 14:58:54", updated_at: "2012-04-05 14:58:56">
(0.2ms)  BEGIN
SQL (1.5ms)  INSERT INTO "assessments" ("account_id", "created_at", "description", "title", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"  [["account_id", 97], ["created_at", Thu, 05 Apr 2012 10:58:56 EDT -04:00], ["description", "Every day we bake fresh cakes to sell in our shop. This is our assessment of the risks involved in this process."], ["title", "Cake baking"], ["updated_at", Thu, 05 Apr 2012 10:58:56 EDT -04:00]]
%%%account is=#这可能是请求之间缓存的内容吗

更新2:
事实上正是这样。正在会话之间缓存当前_租户值。我必须向accounts\u controller添加一个方法,该方法在每次为新创建的帐户创建帐户时定义当前租户值。

它在您的开发环境中与生产设置的关系如何?我怀疑cache_classes=false会导致代码忘记意外记忆的内容。您发布到实际代码中的内容有多相似?@BetjaminRichards为什么不在保存回调后写入此内容,并检查它是否表现出相同的行为,即行为如何weird@BetjaminRichards我同意@dbenhur,我怀疑设置
cache\u classes=false
是错误的原因
%%%%%%%%%%%%%%%%%%%%%     account is = #<Account id: 2, name: "jack cale", plan: "Partnership", billing_zip: nil, no_of_users: 1, no_of_assessments: nil, id_of_admin_user: 2, created_at: "2012-04-05 14:46:54", updated_at: "2012-04-05 14:46:56">
(2.0ms)  BEGIN
SQL (2.2ms)  INSERT INTO "assessments" ("account_id", "created_at", "description", "title", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"  [["account_id", 1], ["created_at", Thu, 05 Apr 2012 10:46:56 EDT -04:00], ["description", "Every day we bake fresh cakes to sell in our shop. This is our assessment of the risks involved in this process."], ["title", "Cake baking"], ["updated_at", Thu, 05 Apr 2012 10:46:56 EDT -04:00]]