I have recently updated one of my apps to Rails 4.2
. When running on my local machine I have noticed that a simple link_to
to a basic show action sometimes takes a very long time to complete.
Here is the link:
= link_to team_members_path(@team) do
Members
Here is my action (in my 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
I use Sphinx
and ThinkingSphinx
for search. When clicking the link I get an unusual long "log" in my console.
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]
This action: Started GET "/users/1"
seems to get called multiple times as you can see above (way more than what I pasted above), which seems to result in a pretty bad performance, even when running on my local machine.
And I'm not quite sure on how I can solve it or what's causing it. Any ideas?
Note
I actually don't know why GET "/users/1"
get called at all in this case. I'm not linking to the users show action.
I have checked it using the Firefox console. See the image below: