I have partial:
<%=render(:partial => ‘blog_post’, :collection => @blogs)%>
This outputs a series of blog posts, however I only want to output the
created_on date if it is different from the last, is there a way to
compare these or create a static variable that I can assign the date to?
I have partial:
<%=render(:partial => ‘blog_post’, :collection => @blogs)%>
This outputs a series of blog posts, however I only want to output the
created_on date if it is different from the last, is there a way to
compare these or create a static variable that I can assign the date to?
You’re saying the @blogs array is already sorted by the created_on date
?
You could call a partial like this one from inside another partial.
I’m pretty sure this is NOT the best way to do it, but i’m pretty new
at rails so this is a fast solution i found for my problem, which in
this case is to either print the created_at date or the updated_at
date according to which one is the newest.
P.S.: The controller just returns the @posts collection through a
paginator :
def list @post_pages, @posts = paginate :posts, :order => ‘id
DESC’, :per_page => 10
end
–Hope i helped a little
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.