How can I convert this haml code to display a dropdown of the menu items instead of a list?
Existing code within our rails 4.0 app:
app/views/application/_archive.html.haml
.sidebar-header=I18n.t('blog.archive')
-archive_dates.each do |date|
.archive-link=archive_link(date, '%B %Y')
app/models/post.rb
def self.archive_dates(audience)
archive_dates = Array.new
published.send(audience).each do |post|
archive_dates << post.publish_date.to_date if archive_dates.count == 0 || post.publish_date.month != archive_dates.last.month || post.publish_date.year != archive_dates.last.year
end
archive_dates
end
app/helpers/application_helper.rb:
def archive_link(archive_date, format)
archive_date = archive_date.to_date
link_to I18n.l(archive_date, format: format), posts_path(month: archive_date.month, year: archive_date.year)
end
This is the output HTML.
https://i.sstatic.net/bFaxf.png
Users are able to select a month and display all posts made during that month. I am looking for the same format and behaviour, but must use a dropdown menu instead.