Class: Monologue::ApplicationController

Inherits:
ApplicationController
  • Object
show all
Includes:
ControllerHelpers::User
Defined in:
app/controllers/monologue/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#all_tagsObject



12
13
14
15
16
17
# File 'app/controllers/monologue/application_controller.rb', line 12

def all_tags
  @tags = Monologue::Tag.order("name").select{|t| t.frequency>0}
  #could use minmax here but it's only supported with ruby > 1.9'
  @tags_frequency_min = @tags.map{|t| t.frequency}.min
  @tags_frequency_max = @tags.map{|t| t.frequency}.max
end

#archive_postsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/monologue/application_controller.rb', line 30

def archive_posts
  @archive_posts = {}
  @first_post_year = DateTime.now.year

  # limit to 100 for safety reasons
  posts = Monologue::Post.published.limit(100)
  if posts.length > 0
    @archive_posts = posts.group_by {
      |post| post.published_at.beginning_of_month.strftime("%Y %-m")
    }
    @first_post_year = posts.last.published_at.year
  end
end

#not_foundObject



19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/monologue/application_controller.rb', line 19

def not_found
  # fallback to the default 404.html page from main_app.
  file = Rails.root.join('public', '404.html')
  if file.exist?
    render file: file.cleanpath.to_s.gsub(%r{#{file.extname}$}, ''),
       layout: false, status: 404, formats: [:html]
  else
    render action: "404", status: 404, formats: [:html]
  end
end

#recent_postsObject



8
9
10
# File 'app/controllers/monologue/application_controller.rb', line 8

def recent_posts
  @recent_posts = Monologue::Post.published.limit(3)
end