[typo] How to view associated resources/attachments

Tim Prentis ruby-forum-incoming at andreas-s.net
Thu Jul 31 16:15:34 EDT 2008


Tim Prentis wrote:
> My environment is Rails 2.0.2, TYPO 5.1.1. running at RailsPlayground
> using the Victor Persson's Dirtylicious theme
> 
> Can someone steer me in the correct direction?  I can upload
> files/attachments and see them in the admin "manage uploads" feature.
> 
> I can also associate uploads with articles when I edit articles(i.e.
> posts).
> 
> The problem: I cannot figure out how to make these 'uploads' visible as
> attachments with the articles(i.e. posts) by simply using the TYPO
> administration features.
> 
> Do I need to modify the default layout or one of the views?  Any ideas
> are greatly appreciated.

I think I found a solution.  This is what I inserted into the partial 
_article.html.erb under my chosen theme 'Dirtylicious'

<div class="author">
    Posted by <cite><%= author_link(article) %></cite>
    <abbr class="published" title="<%= article.published_at.xmlschema 
%>"><%= js_distance_of_time_in_words_to_now article.published_at 
%></abbr>
+    <p></p>
+    <% if Resource.count(:conditions => "article_id = #{article.id}") > 
0 %>
+    Attachments:<br />
+      <% Resource.find(:all, :conditions => "article_id = 
#{article.id}").each do |r| %>
+        &nbsp;&nbsp;&nbsp;&nbsp<%= link_to r.filename, 
this_blog.base_url + "/files/" + r.filename %><br />
    <% end %>
  <% end %>
  </div>

Anybody have any better ideas?

Tim
-- 
Posted via http://www.ruby-forum.com/.


More information about the Typo-list mailing list