0
我在rails4博客應用程序中查看了該代碼。它真的看起來很難看,有人可以幫助我如何在可能的情況下將它變成幫手。Rails創建視圖幫助程序
<h4>Archive</h4>
<%# This is really awful. I know. %>
<% @posts = BlogNgin::Post.order('created_at DESC') %>
<% archive_array = [] %>
<% @posts.each do |post| %>
<% date = post.created_at.strftime("%m") + " " + post.created_at.strftime("%Y") %>
<% if !archive_array.include? date %>
<% archive_array << date %>
<% end %>
<% end %>
<% archive_array.each do |date| %>
<% date = date.split(' ') %>
<%= link_to Date::MONTHNAMES[date[0].to_i].to_s + " " + date[1], blog_ngin.root_path + date[1] + '/' + date[0] %><br />
<% end %>