Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide link url when print in ruby on rails

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?

like image 407
asdjkag Avatar asked Oct 13 '14 01:10

asdjkag


1 Answers

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 
  }
} 
like image 51
Mandeep Avatar answered Oct 18 '22 09:10

Mandeep