[Archivesspace_Users_Group] RoR Guidance/Help with Index Page
Brian Hoffman
brianjhoffman at gmail.com
Thu Jul 23 16:32:28 EDT 2015
Hi Maura,
Are you trying to add a controller to ArchivesSpace or are you trying to create a standalone web app? If the former, you should probably package it as a plugin. More info here:
https://github.com/archivesspace/archivesspace/blob/master/plugins/PLUGINS_README.md
Either way, it would be easier to diagnose your issue if you put an actual repository on Github.
Also, although this doesn’t look right
def index
def pickImage(directory)
dirSize=directory.length
ranNum=0+rand(dirSize)
fileName=directory[ranNum]
return fileName
end
end
Instead:
def index
@filename = pickImage
end
def pickImage(directory)
dirSize=directory.length
ranNum=0+rand(dirSize)
directory[ranNum]
end
Then in a typical RoR system @filename will be available to views/index.html.erb
Brian
On Jul 22, 2015, at 9:42 AM, Maura Carbone <mauraa at brandeis.edu> wrote:
> I can! I just included it in the body of the e-mail because that way people didn't have to go to external links, but here it is on gist:
>
> https://gist.github.com/librarymaura/7a3a303e5c579aaed917
>
> Thanks,
> Maura
>
> On Wed, Jul 22, 2015 at 9:20 AM, Chris Fitzpatrick <Chris.Fitzpatrick at lyrasis.org> wrote:
> Hi Maura,
>
>
> Can't you put your code up on 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
>
> _______________________________________________
> Archivesspace_Users_Group mailing list
> Archivesspace_Users_Group at lyralists.lyrasis.org
> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
>
>
>
>
> --
> 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
> _______________________________________________
> Archivesspace_Users_Group mailing list
> Archivesspace_Users_Group at lyralists.lyrasis.org
> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20150723/d13d843d/attachment.html>
More information about the Archivesspace_Users_Group
mailing list