Class: Monologue::ApplicationController

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

Instance Method Summary collapse

Instance Method Details

#all_tagsObject



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

def all_tags
  @tags = Monologue::Tag.all(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

#not_foundObject



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

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



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

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