Hi I am new to ruby and I have a front ui that I am working on which have an issue displaying certain types of items I am specifying from solr index to display in an mvc ruby blacklight ui, see the snippet below:
<!-- ORAL HISTORY -->
<% elsif document.id =~/oh/ %>
<iframe src="/pdfjs/web/viewer.html?file=%2Fdocpdfview%2F<%[email protected]%>" allowfullscreen webkitallowfullscreen style="width: 100%; height: 640px"></iframe>
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Download</button>
<div class="dropdown-menu">
<a class="dropdown-item" target="_blank" href="/pdfdownload/<%[email protected]%>">PDF</a>
<a class="dropdown-item" target="_blank" href="/txt/<%[email protected]%>">Plain Text</a>
<a class="dropdown-item" target="_blank" href="/dc/<%[email protected]%>">Metadata (Dublin Core)</a>
</div>
<video id="videoarea" controls="controls" poster="" src=""></video>
<% @document["rdf.fedora.hasPart"].each do |item| %>
<ul id="playlist">
<li movieurl="/mp3/<%=item%>"><%=item%></li>
</ul>
<% end %>
<br><br>
<% @document["rdf.fedora.hasPart"].each do |item| %>
<%=item%>
<div class="preview_image" align="left">
<video class="video-js vjs-fluid vjs-default-skin"
controls=""
data-setup='{ "aspectRatio":"640:120"}'
playsinline=""
poster="/pageturnerserver/ajaxp?theurl=http://localhost:8080/fedora/get/<%[email protected]%>/Preview"
preload="none">
<source
src="/mp3/<%=item%>"
type="video/mp4">
</video>
</div>
<% end %>
<!-- AUDIO -->
<% elsif document.id =~/aud/ %>
<div class="preview_image" align="left">
<video class="video-js vjs-fluid vjs-default-skin"
controls=""
data-setup='{ "aspectRatio":"640:120"}'
playsinline=""
poster="/pageturnerserver/ajaxp?theurl=http://localhost:8080/fedora/get/<%[email protected]%>/Preview"
preload="none">
<source src="/mp3/<%[email protected]%>" type="video/mp4">
</video>
</div>
this is not displaying correctly in my ui in case where the " @document["rdf.fedora.hasPart"].each do |item|" item does not have "rdf.fedora.hasPart", is there a way I can build in the ruby code view logic for if rdf.fedora.haspart to handle when ["rdf.fedora.hasPart"] is none and | item| is none?
thanks in advance, any help is appreciated!
You can run any ruby code inside a view in rails. For your problem you can solve like this: