Last active
December 19, 2015 05:19
-
-
Save Brandonmchu/5903759 to your computer and use it in GitHub Desktop.
This file contains 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
#controller | |
def index | |
@bikes = Bike.order('created_at DESC').limit(50).all | |
@bikesnew = @bikes.find_all { |bike| bike.created_at > "2013-07-01 17:58:14" } | |
respond_to do |format| | |
format.js { render :bike_post_ajax } | |
format.html | |
end | |
end | |
#bike_post_ajax.js.erb | |
$('table').prepend("<%= j(render('bike_post', :bike=> @bikesnew)) %>") | |
#_bike_post.html.erb | |
<% bike.each do |single| %> | |
<tr> | |
<td>$<%= single.price %>0</td> | |
<% if single.posted != nil %> | |
<td><%= image_tag single.posted, :height => '200', :width => '200' %></td> | |
<% else %> | |
<td><%= image_tag 'y-u-no-guy.jpg' %></td> | |
<% end %> | |
<td><%= link_to single.title, single.url, :target => '_blank' %></td> | |
<td><%= single.location %></td> | |
<td><%= single.created_at.strftime("%b %d, %H:%M") %></td> | |
</tr> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment