Class: Gluttonberg::Public::BlogsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/gluttonberg/public/blogs_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#locale, #page

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/gluttonberg/public/blogs_controller.rb', line 5

def index
  if Gluttonberg::Blog.published.all.size == 0
    redirect_to "/"
  elsif Gluttonberg::Blog.published.all.size == 1
    blog = Gluttonberg::Blog.published.first
    if Gluttonberg.localized?
      redirect_to blog_path(current_localization_slug , blog.slug)
    else
      redirect_to blog_path(:id =>blog.slug)
    end  
  else
    @blogs = Gluttonberg::Blog.published.all
  end
end

#showObject

Raises:

  • (ActiveRecord::RecordNotFound)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/gluttonberg/public/blogs_controller.rb', line 20

def show
  @blog = Gluttonberg::Blog.published.first(:conditions => {:slug => params[:id]}, :include => [:articles])
  
  if @blog.blank?
    @blog = Gluttonberg::Blog.published.first(:conditions => {:previous_slug => params[:id]})
    
    unless @blog.blank?
       redirect_to blog_path(:id => @blog.slug) , :status => 301
       return
    end
  end
  
  raise ActiveRecord::RecordNotFound.new if @blog.blank?
  @articles = @blog.articles.published
  @tags = Gluttonberg::Article.published.tag_counts_on(:tag)
  respond_to do |format|
     format.html
     format.rss { render :layout => false }
  end
  
end