[Archivesspace_Users_Group] RoR Guidance/Help with Index Page

Maura Carbone mauraa at brandeis.edu
Tue Jul 21 16:02:05 EDT 2015


Hi all,
I've been playing with RoR and html.erb and have a question on how to
implement something I've written. Hoping someone with more experience may
be able to offer a little guidance as the stuff I've read hasn't been super
helpful (in part because I'm already working with pre-built stuff rather
than starting entirely from scratch).

Right now this is our index.html.erb page:

http://findingaids.brandeis.edu/

I wrote some ruby code that would allow the images to be randomized, and
tested said ruby code in irb (so I know I get correctly returned values):

x=Dir["../assets/images/aspace_home/col-1/*.jpg"]
y=Dir["../assets/images/aspace_home/col-2/*.jpg"]
z=Dir["../assets/images/aspace_home/col-3/*.jpg"]

def pickImage(directory)
   dirSize=directory.length
   ranNum=0+rand(dirSize)
   fileName=directory[ranNum]
   return fileName
end

@img1=pickImage(x)
@img2=pickImage(y)
@img3=pickImage(z)

However, I'm not entirely sure how to implement this in RoR/my html.erb
file. I found the index controller (I believe), the site_controller.rb and
put the code inside (and outside on a few tries) the def index end block,
and then added an <img src="<%= @img1 %>" /> to my index.html.erb file but
no variable is found (the page display but its like the img tag is empty).

I also tried something like <% image_tag , '"' +
pickImage(Dir["../assets/images/aspace_home/col-1/*.jpg"]) + '"', :alt =>
"Finding Aids Display Image" %> which just broke the page.

Any guidance on how this works/if I'm even doing this right? I haven't
found anything in archivesspace.out that indicates if what I'm doing is
even being rendered; is there another log somewhere I can check?

-- 
Maura Carbone
Digital Initiatives Librarian
Brandeis University
Library and Technology Services
(781) 736-4659
415 South Street, (MS 017/P.O. Box 549110)
Waltham, MA 02454-9110
email: mauraa at brandeis.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20150721/ff74d537/attachment.html>


More information about the Archivesspace_Users_Group mailing list