0

我想要一个我的控制器的备份,这样我就可以制作一个具有新功能的新控制器。我复制了原件并重新命名了原件。像这样:tickets_controller_9_18_2013.rb 当我将索引中的新功能添加到名为原始控制器名称的新复制控制器中时:tickets_controller.rb 开发环境。在生产环境中使用了原始名称为“tickets_controller.rb”的新功能控制器。使用重命名的原始控制器“tickets_controller_9_18_2013.rb”你如何制作生产环境。使用复制的重命名为原始的?

在我的控制器中,我得到了所有具有相同“reseller_id”属性的用户。然后我将每个用户的票放入数组@tickets。

class Users::TicketsController < ApplicationController

def index
    if admin_user?
    @tickets = []
    all_users = User.find_all_by_reseller_id(current_user.reseller_id)
    all_users.each do |u|
      @tickets += u.tickets
    end
  @tickets = @tickets.paginate(page: params[:page])
  else
   @tickets = current_user.tickets.paginate(page: params[:page])
end

问题是在生产环境中,阵列与开发环境不同。我已经重新启动了 apache 服务器并检查了任何 before_filter 。

关于为什么结果不同的任何想法?

以下是加载阵列时两种环境的日志。

PRODUCTION

Processing by Users::TicketsController#index as HTML 
User Load (0.1ms) SELECT `users`.* FROM `users` WHERE `users`.`remember_token` = 'kaVFM4TddpFadAP8w12Iwg' LIMIT 1 
Reseller Load (0.1ms) SELECT `resellers`.* FROM `resellers` WHERE `resellers`.`id` = 1 LIMIT 1 
Rendered users/_info.html.erb (1.8ms) 
Rendered layouts/_opentag.html.erb (0.1ms) 
Ticket Load (0.1ms) SELECT `tickets`.* FROM `tickets` WHERE `tickets`.`user_id` = 1 LIMIT 30 OFFSET 0 
Rendered users/tickets/index.html.erb within layouts/application (5.9ms) 
Rendered layouts/_header.html.erb (0.0ms) 
Rendered layouts/_footer.html.erb (0.1ms)


DEVELOPMENT

Processing by Users::TicketsController#index as HTML 
User Load (0.1ms) SELECT `users`.* FROM `users` WHERE `users`.`remember_token` = 'E0_tHb5p-7XTZAB8XcxtGg' LIMIT 1 
User Load (0.1ms) SELECT `users`.* FROM `users` WHERE `users`.`reseller_id` = 1 
Ticket Load (0.1ms) SELECT `tickets`.* FROM `tickets` WHERE `tickets`.`user_id` = 1 
Ticket Load (0.1ms) SELECT `tickets`.* FROM `tickets` WHERE `tickets`.`user_id` = 6 
Ticket Load (0.1ms) SELECT `tickets`.* FROM `tickets` WHERE `tickets`.`user_id` = 7 
Reseller Load (0.1ms) SELECT `resellers`.* FROM `resellers` WHERE `resellers`.`id` = 1 LIMIT 1 
Rendered users/_info.html.erb (2.3ms) 
Rendered layouts/_opentag.html.erb (0.1ms) 
Rendered users/tickets/index.html.erb within layouts/application (67.9ms) 
Rendered layouts/_header.html.erb (0.0ms) 
Rendered layouts/_footer.html.erb (0.1ms)

如果我添加代码以重命名原始“tickets_controller_9_18_2013.rb”生产环境。使用它并且该功能有效。如何使用命名为原始控制器的新控制器?'tickets_controller.rb' 谢谢

4

2 回答 2

1

您应该在生产中重新启动应用程序。Rails 在生产模式下缓存类。要重新加载类,请重新启动应用程序。

于 2013-09-20T06:09:18.050 回答
0

我必须将日期放在原始名称的前面,如下所示:

09_13_2013_tickets_controller.rb

代替:

tickets_controller_09_19_2013.rb

我不知道这很重要。

于 2013-09-20T06:16:16.617 回答