[Archivesspace_Users_Group] RoR Guidance/Help with Index Page

Chris Fitzpatrick Chris.Fitzpatrick at lyrasis.org
Wed Jul 22 09:20:55 EDT 2015


Hi Maura,


Can't you put your code up on http://gist.github.com/ <http://gist.github.com/>

and send a link to it? What you're doing sounds about right, but it'll be easier for me to see what's up if I can look at the code...

b,chris.


Chris Fitzpatrick | Developer, ArchivesSpace
Skype: chrisfitzpat  | Phone: 918.236.6048
http://archivesspace.org/


________________________________
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Maura Carbone <mauraa at brandeis.edu>
Sent: Tuesday, July 21, 2015 10:02 PM
To: Archivesspace Users Group
Subject: [Archivesspace_Users_Group] RoR Guidance/Help with Index Page

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<mailto:mauraa at brandeis.edu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20150722/046d027c/attachment.html>


More information about the Archivesspace_Users_Group mailing list