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

  • Home
  • SEARCH
  • 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 7539971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:31:19+00:00 2026-05-30T07:31:19+00:00

I’ve been back and forth through a few posts here, and also checked out

  • 0

I’ve been back and forth through a few posts here, and also checked out the Railscast for mobile detection (#199). I have a rails3 application that uses jquery and ajax and format.js and works fine. Now I’m trying to extend the applicaiton to mobile devices.

I’m using jquery mobile and everything is rendering fine, but when I use a remote => true switch on a link_to, it’s not processing the request as JS (which it normally does in the desktop version).

Here is the link code:

<%= link_to 'Up', '/posts/' + String(rbpost.id) + '/upvote', :remote => true, :class => 'upvote', "data-role" => "button", "data-icon" => "arrow-u", "data-iconpos" => "notext" %>

It’s processing as HTML

Started GET "/posts/3/upvote" for 127.0.0.1 at 2012-02-08 11:37:59 -0500

  Processing by PostsController#upvote as HTML

. . .and complains there is no template:

ActionView::MissingTemplate (Missing template posts/upvote, application/
upvote with {:handlers=>[:erb, :builder, :coffee], :formats=>[:mobile], :locale=
[:en, :en]}. Searched in:
  * "C:/rubydemo/testapp/app/views"
):
  app/controllers/posts_controller.rb:74:in `upvote'

Here is how things are coded:

application_controller.rb:

class ApplicationController < ActionController::Base
  protect_from_forgery
  before_filter :adjust_format_for_mobile

private
  # Set iPhone format if request 
  def adjust_format_for_mobile
    if mobile_request?
        if request.format == :js
            request.format = :mobilejs
        else
            request.format = :mobile
        end
    end
  end

# Return true for mobile requests 
  def mobile_request?
    return request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Mobile\/.+Safari)/]
    #return true
    #I set this to return true always when I'm debugging on the desktop
  end  
end

mime_types.rb:

# Be sure to restart your server when you modify this file.

# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
 Mime::Type.register_alias "text/html", :mobile
 Mime::Type.register_alias "text/javascript", :mobilejs

posts_controller.rb:

  def upvote
    @post = Post.find(params[:id])
    @post.upvote
    @post.save

    respond_to do |format|
      format.js 
      format.mobilejs
      format.html { redirect_to @post }
      format.json { render json: @post }
    end
  end

I have upvote.js.erb and upvote.mobilejs.erb in my views/posts directory. It’s registering the :mobile type, but for some reason not doing the javascript thing when it needs to. Any ideas?

Thanks

  • 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-30T07:31:21+00:00Added an answer on May 30, 2026 at 7:31 am

    I guess this happens as the JQuery Mobile and Ruby on Rails Ajax Handling messes up. I fixed the same issue by explicity disabling JQM ajax functionality for the form:

    <%= form_for(AgendaItem.new, :remote => true, :html =>{ "data-ajax" => false}) do |f| %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.