I have @comments that lets you speak 17 posts
What I want is the last 4: 14,15,16,17
I tried:
<% @comments.take(4).each do |comment| %>
But this returns the first 4 .. How can I take the last 4 comments, not the first 4
thanks
You can also do:
@comments.last(4)...
<% @comments.reverse.take(4).each do |comment| %>
Source: https://habr.com/ru/post/1333319/More articles:Move div element to middle of screen in animation - javascriptThe shortest sequence of nodes, although an unweighted graph is algorithmTexture tutorial mapping a map to an Open GL ES sphere? - iphoneIs there a script that allows me to edit multiple files as if they were a single file in VIM? - vimBlit Queue Optimization Algorithm - c ++Expander Button Custom Style ExpandableListView - androidC ++ shell code to extract a .zip file? - c ++Is it good practice to use meta refresh tags for redirection instead of the header () function in php? - redirectmalloc undefined - cJavascript virtue and usage is super: is this possible? - javascriptAll Articles