5

When I print my report

<td><%= link_to (index + 1).to_s, data_report_path(datum.id), target: "_blank" %></td>

in print view,I want the index displayed ,say "1".but when I do print,it shows "1(/report_data/1/report)"

I'm using ruby on rails.

what I have tried:

1.I have added following code in my app/assets/stylesheets/application.css.scss

@media print {
    .noprint {display:none !important;}
    a:link:after, a:visited:after {  
      display: none;
      content: "";    
    }
}

2.add class:'no-print' so the code becomes

link_to (index + 1).to_s, data_report_path(datum.id), class:'no-print',target: "_blank"

but neither works.

Where should I add & what code should I add to hide this link when print?

7
  • Can you explain what are you trying to do? What do you mean by instead of just print out index,it also prints the link.how can I get just the index printed?
    – Mandeep
    Oct 13, 2014 at 3:13
  • @Mandeep I have edit this part..
    – asdjkag
    Oct 13, 2014 at 3:27
  • so you mean it's showing href?
    – Mandeep
    Oct 13, 2014 at 3:30
  • @Mandeep yes,I want only the text displayed without the link
    – asdjkag
    Oct 13, 2014 at 3:32
  • Quick observation, the class in the link helper is no-print but in the css rule it's noprint.
    – Candide
    Oct 13, 2014 at 3:43

1 Answer 1

6

Just tested it in fiddle and it shows up as normal text in print view but when you are using bootstrap or foundation it shows up as you described. Since you are not using bootstrap so i think some other plugin is applying this print style on anchor

a[href]::after {
  content: " (" attr(href) ")"
}

So you need to override this style in your custom css file. You can do it by

@media print {
  a[href]:after {
    content: none !important;
    // use important only if you are not able to override it by normal styling 
  }
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.