Module: Ecm::Blog::ApplicationHelper

Defined in:
app/helpers/ecm/blog/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#blog_render_monthly_navigationObject

Prerequisites:

You have to add the simple-navigation gem to your Gemfile:

# Gemfile
gem 'simple-navigation'

Usage:

# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  helper Ecm::Blog::ApplicationHelper
end

# app/views/layouts/application.html.haml
= blog_render_monthly_navigation if controller.class.name.deconstantize == 'Ecm::Blog'


21
22
23
24
25
# File 'app/helpers/ecm/blog/application_helper.rb', line 21

def blog_render_monthly_navigation
  posts = Ecm::Blog::Post.published.all.pluck(:created_at)
  posts_by_month = posts.group_by {|t| t.beginning_of_month }
  render partial: 'ecm/blog/posts/monthly_navigation', locals: { posts_by_month: posts_by_month}
end