I have a collection that I rendering but would like to show a border between items and not at the end. Is this possible?
render :partial => 'classrooms/classroom_result', :collection => @result, :as => :classroom
_classroom_result.html:
<div style='border-bottom:1px solid #CCCCCC;'>
<%= classroom.name %>
</div>
Basically is there a way to differentiate the last item in the collection for styling purposes? In this example I don’t want to there to be css of border-bottom on the last item because I have a border surrounding the entire collection.
First off this is a CSS issue, not really a Rails issue.
To do this, you need a proper stylesheet. I do not think you can do this with an inline style as you are. Next your
<div>needs a CSS class to identify this list of<div>s and then you use the:last-childpseudo-selector to disable the border on the last element.In your stylesheet:
In your partial:
That should do it. Also, :last-child will not work in <= IE8, but will in most other relatively recent browsers.