Last active
August 29, 2015 14:02
-
-
Save mattjstar/259d54f18bac846367b4 to your computer and use it in GitHub Desktop.
AJAX for Articles! (Thinkful Office Hour: 6/23/14)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% 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 %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resources :garments do | |
member do | |
get :see_more_articles | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.see-more-articles').hide(); | |
$('.article_collection').append("<%= j render 'garments/articles_collection', articles: @articles, garment: @garment %>"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment