我最近把我的一个应用程序升级到了Rails 4.2
。当在本地机器上运行时,我发现一个简单的link_to
指向一个基本的show action有时需要很长时间才能完成。
这就是链接:
= link_to team_members_path(@team) do
Members
这是我的操作(在我的 MembersController
中):
def index
@team = Team.find_by_id(params[:team_id])
if params[:search].present?
@members = Member.search ThinkingSphinx::Query.escape(params[:search]), :with => {:team_id => @team.id}, :page => params[:page], :per_page => 10
else
@members = Member.search params[:search], :with => {:team_id => @team.id}, :page => params[:page], :per_page => 10
end
end
我使用Sphinx
和ThinkingSphinx
进行搜索。当点击链接时,我的控制台上出现了异常长的“日志”。
Started GET "/users/1" for ::1 at 2014-12-24 11:24:40 +0100
Processing by UsersController#show as JS
Parameters: {"id"=>"1"}
[renders stuff etc]
...
Started GET "/users/1" for ::1 at 2014-12-24 11:24:40 +0100
Processing by UsersController#show as JS
Parameters: {"id"=>"1"}
[renders stuff etc. with the same timestamp as above]
...
Started GET "/users/1" for ::1 at 2014-12-24 11:24:40 +0100
Processing by UsersController#show as JS
Parameters: {"id"=>"1"}
[renders stuff etc. with the same timestamp as above]
这个操作:
Started GET "/users/1"
似乎会被多次调用,如上所示(比我上面粘贴的要多得多),这似乎导致性能非常差,即使在我的本地机器上运行也是如此。我不确定该如何解决它或者是什么原因导致了它。有什么想法吗?
注意:
实际上,我不知道为什么在这种情况下会调用
GET "/users/1"
。我没有链接到用户显示操作。我已经使用Firefox控制台进行了检查。请参见下面的图像: