Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple anchor tag making double GET request in rails
    primarykey
    data
    text
    <p>I have a strange problem that some of the other double request questions failed to answer. I have a super simple application that is basically a comic book. Whenever I click the link to go to page two, my server logs two GET requests. I dont remember this always happening. Any ideas what could be causing the duplicate GET requests?</p> <p>ROUTES.rb</p> <pre><code>root to: 'episodes#index' resources :episodes, :only =&gt; [:index] post 'pusher/auth' match '/episodes/:page', to: 'episodes#index', via: 'get' </code></pre> <p>INDEX.HTML.ERB</p> <pre><code>&lt;a id="ep-link-2" href="/episodes/2"&gt;&amp;nbsp2&amp;nbsp&lt;/a&gt; </code></pre> <p>EPISODESCONTROLLER.RB</p> <pre><code>def index @current_episode = params[:page].to_i || 1 ep_folder = Dir.new("app/assets/images/episodes") #returns 0 if folder name is not a number, meaning it's not an actual episode ep_folder = ep_folder.reject { |file| file.to_i == 0 } @total_episodes = ep_folder.count ip = request.remote_ip Visitor.has_visited?(ip) total_site_visits = Visitor.total_site_visits total_uniques = Visitor.total_uniques data = {:total_site_visits =&gt; total_site_visits, :unique_visits =&gt; total_uniques } @visit_counts = [total_uniques, total_site_visits] Pusher['connections'].trigger('new_connection', data) @visitor_data = { :total_site_visits =&gt; total_site_visits, :unique_visits =&gt; total_uniques } respond_to do |format| format.html { render :index } format.json { render :json =&gt; @visitor_data } end end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload