Rails 4.2 - performance issue

I recently updated one of my applications to Rails 4.2. When running on my local machine, I noticed that a link_toshow that is simple for the main action sometimes takes a lot of time.

Here's the link:

= link_to team_members_path(@team) do
  Members

Here is my action (in mine 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 Sphinxand ThinkingSphinxfor search. When I click on the link, I get an unusual long "log" on 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"it seems to be called several times, as you can see above (the path is larger than what I pasted above), which apparently leads to rather poor performance even when working on my local computer.

And I'm not quite sure how I can solve this or what it causes. Any ideas?

Note

, GET "/users/1" . show users.

Firefox. . :

enter image description here

+4
1

, , Javascript, (_form.html.haml). , Bootstrap ​​ . Javascript Ajax. , , Ajax:

:javascript
  $(document).ready(function() {

  $.ajax({
    url: "#{update_idea_team_path}",
    data: {
      team_id : $('#select_idea_team').val()
    },
    dataType: "script"
  });

- , , , . Javascript Ajax .coffee.js , , .

+1

Source: https://habr.com/ru/post/1568868/


All Articles