tommy-taco
tommy-taco

Reputation: 227

Cannot get Masonry-Rails Gem to work in my app

so I have scoured stackoverflow and found some similar articles but nothing has worked for me yet. I am creating a rails app and I want to use the Masonry for my layout. I have tried uploading the js as described in this post, but I could not get it to work no matter how many times I tried (yes I matched all the correct IDs and classes). I know the gem is working because the CSS is loading fine, I just cant get the JS to work. Here is what I have at the moment

Gemfile:

# masonry layout
gem 'masonry-rails'

application.js:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require_tree . 
//= require masonry/jquery.masonry  

index.html.erb:

<div class="center">

<div id="masonry-container" class="transitions-enabled infinite-scroll clearfix">
    <%= render @products %>
</div>

    <div class="paginator">
    <%= will_paginate @products, renderer: BootstrapPagination::Rails %>
    </div>
</div>

_products.html.erb

<div class="box">
<% gfyid = product.gfy.to_s.gsub("http://gfycat.com/", "") %>
<h2><%= product.name %></h2>
<div class="gfySize">
    <div class="gfyitem" data-title=false data-autoplay=false data-controls=false data-expand=false data-id="<%= gfyid %>"></div>
</div>

I am so lost, I have been working on this for hours trying everything. The CSS is working/looking fine but I am just struggling with the js. Would appreciate any help thank you so much!

Upvotes: 7

Views: 1177

Answers (1)

Andrew Hendrie
Andrew Hendrie

Reputation: 6415

Try installing it manually, putting the masonry file in the vendors folder and writing the code in the product.js section.

Upvotes: 1

Related Questions