I want to display attachments in my asset view and I have this in my view:
<% if @asset.attachments.size > 0 %开发者_如何学C>
<% @asset.attachments.each_with_index do |attachment| %>
<%= image_tag attachment.to_s %>
<%end%>
<%end%>
and I have this in my controller (just the basic):
def show
@asset = Asset.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @asset }
end
end
When I want it to show the name (which is in the attachment field of the attachments table). But the code only gives me
#<attachment #<attachment
as output in the view. What am I missing?
Calling attachment
here is just referencing the class it looks like. Is there a name field for attachment so you could call something like <%= image_tag attachment.name %>
?
精彩评论