0

I'm a novice RoRr and I'm building my company's website on RefineryCMS.

I've properly created an engine for my Boss' publications, within which I included a pdf:resource column and have uploaded all the articles to my backend. Everything works - renders properly and downloads work.

HOWEVER, I also want to be able to view those pdf's as a _blank target through a link_to on the article.title. SEE CODE BELOW !!!XXXXXXXXX_path , or any useable variation, is what I'm looking for!!!

The important thing is that the corresponding PDF is being rendered. That is, I know I can't manually code individual links while using the [.each do] loop.

I'm sure there is a way to get this done but, as I said, I'm a novice and could use some help.

here's the code:

<section id="body_content">
<section id="body">
    <section id=articles>
        <% @articles.each do |article| %>
            <div class=wrapper>
                <div class=particle>
                    <h1><%= link_to article.title, **(XXXXXXXXXXXXXXX.pdf)**, :target => '_blank' %></h1>
                        <p><span class=publisher><%= article.publication %></span>,
                            <span class=year><%= article.year %></span>
                        </p>
                    <% if article.pdf.present? %>
                        <%= link_to image_tag("/assets/pdf.png", :size => "30x30"), article.pdf.url, :title => "PDF download", :class => "pdflink" %>
                    <% else %>
                        pdf
                    <% end %>
                </div>
            <% end %>
        </div>
    </section>
</section>

Any help is much appreciated.

*SIDE NOTE: my next task is to add a link to email the article (as an attachment) to a third party. Again, I'd imagine there's something in ActionMailer that can help with this but any help before I get started would be great.

much obliged.

cjl
  • 1
  • 1

1 Answers1

0

Sorry I read your question wrong. Try this instead

To indicate to the browser that the file should be viewed in the browser:

Content-Type: application/pdf
Content-Disposition: inline; filename.pdf

To have the file downloaded rather than viewed:

Content-Type: application/pdf
Content-Disposition: attachment; filename.pdf
SupaIrish
  • 766
  • 8
  • 17
  • Thanks for the help. Given your intro, I feel like you left a previous answer that specified where to enter this, but it's not showing up. – cjl Sep 04 '13 at 15:22