Display image only if instance variable contains its type
I have stored the @type of directories that have files in them.
def index
@results = []
directory_path = "public/files/marketing/voip"
if Dir.entries(directory_path).empty? &&
arrays_of_strings_to_check_against.any?{ |o| @type =~
/\b#{Regexp.escape(o)}\b/ }
@results << @type
@view = 'types'
end
Now I want to use @results that have the @type of directories that have
files in them to only show those directories with the @type saved.
<%# Loop through array and create html view for each folder %>
<% @results.each do |o| %>
<div class="row images">
<div class="span3">
<h5 class="pagination-centered">
<%= link_to (image_tag "/img/folder.jpg", alt: "Buyer's
Guides", width: "75px"), action: "index", filter: @filter,
type: "buyers_guides" %>
<%= link_to "Buyer's Guides", action: "index", filter:
@filter, type: "buyers_guides" %>
</h5>
</div>
<div class="span3">
<h5 class="pagination-centered">
<%= link_to (image_tag "/img/folder.jpg", alt: "Datasheets",
width: "75px"), action: "index", filter: @filter, type:
"datasheets" %>
<%= link_to "Datasheets", action: "index", filter: @filter, type:
"datasheets" %>
</h5>
</div>
<div class="span3">
<h5 class="pagination-centered">
<%= link_to (image_tag "/img/folder.jpg", alt: "Documents", width:
"75px"), action: "index", filter: @filter, type: "documents" %>
<%= link_to "Documents", action: "index", filter: @filter, type:
"documents" %>
</h5>
</div>
</div>
I see all the directories instead of just the ones in @results.
No comments:
Post a Comment