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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:22:50+00:00 2026-05-19T12:22:50+00:00

I have a column in my HTML table with negative and positive numbers. If

  • 0

I have a column in my HTML table with negative and positive numbers. If the number is negative, I display a green arrow next to the number. If it’s positive, I display a red arrow next to the number.

The neatest way I can think of doing this is to make a helper called show_with_arrow where I pass in the number. I’m trying to make the helper method pass back something like -6 ⇓ or 10 ⇑, the arrows being images.

In my show view:

<td><%= show_with_arrow keyword.compare_to(7.day.ago) %></td>

In my helper class:

def show_with_arrow(position_change)
    if position_change > 0
      "#{position_change} #{image_tag('bad_arrow.gif')}"
    elsif position_change < 0
      "#{position_change} #{image_tag('good_arrow.gif')}"
    else
      position_change
    end
end

And it’s outputting:

-6 <img alt="Good_arrow" src="/images/good_arrow.gif?1295578152" />

instead of

-6 ⇓
  • 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-19T12:22:51+00:00Added an answer on May 19, 2026 at 12:22 pm

    I think you need to use raw() like so:

    raw("#{position_change} #{image_tag('bad_arrow.gif')}")
    

    You’re on rails 3, right?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html table and in one column I have dropdown select. I
i have a list of textboxes in a column of a html table. The
I have an HTML table with several columns and I need to implement a
I need a select from table which does not have column that tells when
I have a matrix that I am showing in html table. I have my
i have an html table in my asp.net mvc view an i am running
I have a HTML table where I: Include explicit table width. Include explicit width
I have column that contains strings. The strings in that column look like this:
I have a column of data that contains a percentage range as a string
I have a column which is of type nvarchar(max). How do I find the

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.