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 9046631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:42:04+00:00 2026-06-16T11:42:04+00:00

I have a reddit-like app that allows users to vote for links with the

  • 0

I have a reddit-like app that allows users to vote for links with the Activerecord Reputation System gem.

I am trying to create a mobile version, based on Railscast#199, in which a mobile.erb format is used if the site is accessed via a mobile device.

The voting method works fine in the non-mobile format (defaults to javascript, but also works in html), but returns an error in mobile as follows. Note that it is trying to Get instead of Post.

Started GET "/links/98/vote?type=like" for 127.0.0.1 at 2012-12-25 19:16:45 -0500
ActionController::RoutingError (No route matches [GET] "/links/98/vote"):

What might be causing this? Is the before_filter preventing the javascript? How can I fix this? Thanks much for your input!

application_controller.rb

before_filter :prepare_for_mobile

def prepare_for_mobile
  session[:mobile_param] = params[:mobile] if params[:mobile]
  request.format = :mobile if mobile_device?
end

def mobile_device?
  if session[:mobile_param]
    session[:mobile_param] == "1"
  else
    request.user_agent =~ /Mobile/
  end
end
helper_method :mobile_device?

routes.rb

resources :links do
  member { post :vote }
end

links_controller.rb

def vote
  value = params[:type] == "like" ? 1 : 0
  @link = Link.find(params[:id])
  @link.add_or_update_evaluation(:link_votes, value, current_user)
  respond_to do |format|
    format.html { redirect_to :back }
    format.mobile { redirect_to :back }
    format.js
  end
end

_link.mobile.erb

<div id="link_<%= @link.id %>">
  <%= link_to "like", vote_link_path(@link, type: "like"), method: "post", remote: true %>
</div>

<div id="link_points_<%= @link.id %>">
  <%= @link.reputation_for(:link_votes).to_i %>
</div>

vote.js.erb

$('#link_<%= @link.id %>').html("<%= j link_to "up", vote_link_path(@link, type: "like"), method: "post", remote: true %>");


$('#link_points_<%= @link.id %>').html("<%= @link.reputation_for(:link_votes).to_i %>;
  • 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-06-16T11:42:05+00:00Added an answer on June 16, 2026 at 11:42 am

    Here’s what I did:

    config/initializers/mime_types.rb

    Mime::Type.register_alias "text/html", :mobile
    Mime::Type.register_alias "text/javascript", :mobilejs /* newly added mobilejs */
    

    application_controller.rb

    before_filter :prepare_for_mobile
    
    def prepare_for_mobile
      session[:mobile_param] = params[:mobile] if params[:mobile]
      if mobile_device?
        if request.format == :js
          request.format = :mobilejs /* newly added mobilejs format */
        else
          request.format = :mobile
        end
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app which essentially a conversation system (much like reddit). Where a
We have a PHP website like reddit, users can vote for the stories. We
I want to create something like reddit where they have comments, then replies to
I am trying to create a .csv file with data that I have stored
I want to have a comments section in my app that looks like this:
I have an app that's a simple clone of reddit. Using Devise you can
I came across this code on reddit . I would have thought that type
I currently have a reddit-clone type website. I'm trying to recommend posts based on
I have two tables -- an article table and a vote table. Users can
I'm building a site that has somewhat reddit-like functionality. I want user-submitted content to

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.