Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 3.1 Ajax: Why doesn't my link_to's with :remote => true generate a JS request?
    primarykey
    data
    text
    <p>I'm implementing Ajax into my existing Rails 3.1 app. I'm comparing with <a href="http://wowkhmer.com/2011/09/19/unobtrusive-ajax-with-rails-31/" rel="nofollow">Samnang Chhun's excellent tutorial</a> - his works, mine doesn't.</p> <p>This is my link_to:</p> <pre><code>&lt;%= link_to('Do some Ajax!', @activity, :remote =&gt; true) %&gt; </code></pre> <p>This my controller:</p> <pre><code>class ActivitiesController &lt; ApplicationController respond_to :html, :js # ... def show @activity = Activity.find(params[:id]) respond_with @activity end # ... end </code></pre> <p>My <code>views/activities</code> folder contains both a <code>show.html.erb</code> and a <code>show.js.erb</code>.</p> <p><strong>UPDATE:</strong> This is my included JavaScript files:</p> <pre><code>&lt;script src="/assets/jquery.js?body=1" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/assets/jquery_ujs.js?body=1" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/assets/activities.js?body=1" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/assets/add2home.js?body=1" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/assets/jquery.dropdownPlain.js?body=1" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/assets/application.js?body=1" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>When I click it, the page refreshes, a straight HTML request, which is also verified by the server output (see line 2):</p> <pre><code>Started GET "/activities/18-leka-titta-pa-mig" for 127.0.0.1 at 2013-03-13 20:58:43 +0100 Processing by ActivitiesController#show as HTML Parameters: {"id"=&gt;"18-leka-titta-pa-mig"} Activity Load (0.4ms) SELECT "activities".* FROM "activities" WHERE "activities"."id" = $1 LIMIT 1 [["id", "18-leka-titta-pa-mig"]] WEBSITE: Babycenter.com Tag Load (0.8ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = 18 AND "taggings"."taggable_type" = 'Activity' Rendered layouts/_footer.html.erb (0.6ms) Rendered activities/show.html.erb within layouts/application (63.4ms) Rendered layouts/_facebook_sdk.html.erb (0.1ms) Rendered activities/_filter_tabs.html.erb (3.1ms) Completed 200 OK in 107ms (Views: 79.8ms | ActiveRecord: 21.6ms) </code></pre> <p>What am I doing wrong?</p>
    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.
    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