Skip to content

Instantly share code, notes, and snippets.

@mattjstar
Last active August 29, 2015 14:02
Show Gist options
  • Save mattjstar/259d54f18bac846367b4 to your computer and use it in GitHub Desktop.
Save mattjstar/259d54f18bac846367b4 to your computer and use it in GitHub Desktop.
AJAX for Articles! (Thinkful Office Hour: 6/23/14)
<% articles.each_slice(4) do |four_articles| %>
<div class="row">
<% four_articles.each do |article| %>
<%= render 'garments/article', article: article, garment: @garment %>
<% end %>
</div>
<% end %>
def show
@garment = Garment.find(params[:id])
end
def see_more_articles
@garment = Garment.find(params[:id])
@articles = @garment.articles - @garment.articles.limit(4)
respond_to do |format|
format.js
end
end
resources :garments do
member do
get :see_more_articles
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment