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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:03:55+00:00 2026-06-06T16:03:55+00:00

I have a voting mechanism where you can vote up/down on an entry within

  • 0

I have a voting mechanism where you can vote up/down on an entry within a given contest. There are a limited number of votes and every entry has an up and a down button next to it. I would like the up button to change styles if there are no votes remaining and the down button to change styles when the user hasn’t voted yet.

In my _entry.html I have:

       <div class="vote-box">
        <% if !current_user.voted?(entry) %>
          <%= link_to '-', entry_vote_down_path(entry), method: :post, remote: true, :class => "btn btn-success vote down disabled" %>
        <% else %>
          <%= link_to '-', entry_vote_down_path(entry), method: :post, remote: true, :class => "btn btn-success vote down" %>
        <% end %>


        <% if current_user.votes_remaining(entry.contest) == 0 %>
          <%= link_to '+', entry_vote_up_path(entry), method: :post, remote: true, :class => "btn btn-success vote up disabled" %>
        <% else %>
          <%= link_to '+', entry_vote_up_path(entry), method: :post, remote: true, :class => "btn btn-success vote up" %>
        <% end %>

          <p><%= pluralize entry.votes.count, 'total vote' %> </p>

The entry_vote_up_path, for example, ultimately triggers vote_up in the EntriesController:

def vote_up
  entry = Entry.find(params[:entry_id])
  current_user.vote_up!(entry)
  flash[:notice] = "Vote successfully counted."

  respond_to do |f|
   f.js { @entry = entry }
  end
end

I then have a vote_up.coffee:

  <% if current_user.votes_remaining(@entry.contest) == 0 %>

  $('#entry_<%= @entry.id %> .vote-box a.vote_up').replaceWith('<%=   vote_up_button_for_entry_disabled(@entry) %>')

  <% else %>

  $('#entry_<%= @entry.id %> .vote-box a.vote_up').replaceWith('<%= vote_up_button_for_entry(@entry) %>')

The vote_up_button_for_entry does the same as the link_to in the original html file, I know this works. I feel like the problem is with the “a.vote_up”, but I just can’t figure it out. 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-06-06T16:03:57+00:00Added an answer on June 6, 2026 at 4:03 pm

    Your coffeescript file is looking for a vote_up class, but you don’t actually use that class anywhere. Instead, you use two separate classes, vote and up.

    Either change the link_to entries to actually use vote_up and vote_down, or do something like this:

    $('#entry_<%= @entry.id %> .vote-box a.vote.up').replaceWith('<%=   vote_up_button_for_entry_disabled(@entry) %>')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a voting mechanism on the site. When people vote up or down,
Say I have a voting table, where users can vote on values up, down,
I have an up/down vote mechanism that is updated via ajax. Originally, the code
I have am trying to create a simple voting page. There are a few
Are there any requirements gathering tools that have a voting system built in? Using
I have a model called Vote that gets changed very frequently (people voting on
We have a voting mechanism that we want to restrict to only allow one
I have a voting system with two models: Item(id, name) and Vote(id, item_id, user_id).
I have a voting site that my users can use to promote my game.
In my page I have a voting possibility. Each object can be liked with

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.