Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6926909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:58:45+00:00 2026-05-27T10:58:45+00:00

As seen below, I’m in a Rails 3.1 app attempting to POST with a

  • 0

As seen below, I’m in a Rails 3.1 app attempting to POST with a link_to using a block:

views/wall/_problem.html.erb

<li data-icon="check">
<%= link_to(
  url_for(
    :controller => 'completed_problems',
    :action => 'create',
    :problem_id => "#{problem.id}"),
  {:class => "wall_problem",
  :confirm => "Climbed it?",
  :remote => true,
  :"data-type" => "json",
  :method => "POST"}) do %>
<div>stuff</div>
<% end %>
</li>

views/wall/show.html.erb

<% content_for :content do %>
  <div data-role="content">
  <ul data-role="listview">
    <%= render :partial => 'problem', :collection => @wall.live_problems.sort %>
  </ul>
<% end %>

<script>
  $('.wall_problem').live('ajax:success', function() {
    alert("Success!");
  });
</script>

This particular POST is directed to the following controller action:

controllers/completed_problems_controller.rb

class CompletedProblemsController < ApplicationController
  # POST /completed_problems
  def create
    @problem = Problem.find(params[:problem_id]
    @completed_problem = @problem.completed_problems.build
    if @completed_problem.save
      render :json => { }
    else
      render :json => { :location => root_url}
    end
  end
end

As you can see from the logs below, the POST does succeed as it should, but for some reason the app executes a GET to the exact same URL at the same time.

LOGS

Started POST "/completed_problems?problem_id=11" for 127.0.0.1 at 2011-12-11 13:13:06 -0500
  Processing by CompletedProblemsController#create as JSON
  Parameters: {"problem_id"=>"11"}
  # SQL stuff snipped from here
Completed 200 OK in 116ms (Views: 3.0ms | ActiveRecord: 2.6ms)

Started GET "/completed_problems?problem_id=11" for 127.0.0.1 at 2011-12-11 13:13:06 -0500
  Processing by CompletedProblemsController#index as HTML
  Parameters: {"problem_id"=>"11"}
Rendered completed_problems/index.html.erb within layouts/application (29.6ms)
Completed 500 Internal Server Error in 36ms

The problem does sound similar in scope to jQuery ajax POST causes an immediate GET to the same URL but this is using jquery_ujs and I don’t believe I’ve left any custom jquery code sitting around. As such, I can’t perform the solution suggested in that problem of adding a ‘return false;’

I suspect that issue is in one of three places:

  1. I have incorrect syntax for using the link_to element with a block
  2. My handling of the request within the controller is incorrect
  3. I somehow have doubled my jquery_ujs (which I really don’t think to be true, but it could be here)

EDIT

Narrowing down the problem #1:

I changed my script to the following,

<script>
  $('.wall_problem').live('ajax:beforeSend', function() {
    return false;
  });
</script>

And discovered that the POST now did not go through, but the GET did, confirming that problem seems to be that the AJAX handler is picking up the link and submitting it as a POST properly, but is not intercepting the GET that the browser submits.

Narrowing down the problem #2:

I did not mention it at first, but I am using Jquery-mobile. Now in restoring the script tag to its previous form and then disabling jquery-mobile, I have tried the link again and it now does not submit the GET but does submit the POST. That leads me to believe that there’s some issue with how jquery-ujs and jquery mobile are interacting with the link.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:58:46+00:00Added an answer on May 27, 2026 at 10:58 am

    Based on the info I included in the above edit, I continued down the path of testing Jquery Mobile and was able to solve.

    First, I updated to Jquery Mobile v1.0, which adds the linkBindingEnabled global config (http://jquerymobile.com/demos/1.0/docs/api/globalconfig.html):

    Second, I set that config to False:

    $(document).bind("mobileinit", function(){
      $.mobile.linkBindingEnabled = false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I generated a ListView as seen below I don't have enough rep to post
I'm using a simple unzip function (as seen below) for my files so I
I've included the QMutex header and using it as seen below. But I get
I'm using the HttpWebRequest class asynchronously as seen below (its a Windows application) private
I am creating my application using backbone.js As seen below I have a layoutView
I have a Perl script which nests foreach loops as seen below. It takes
I have an XML document containing contact information as seen below: <contact type=individual> <firstname>Some</firstname>
I have a long function, as seen below: hash_correct = hashlib.md5(salt + password)).digest().encode(base64) I'd
Does anyone know how to implement an action badge, like the ones seen below
I have a variable that contains an array from form data, seen below: $option1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.