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

- (Object) index



5
6
7
8
9
10
11
12
13
14
15
16
# 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
    redirect_to blog_path(blog.slug)
  else
    @blogs = Gluttonberg::Blog.published.all
  end
  
  
end

- (Object) show

Raises:

  • (ActiveRecord::RecordNotFound)


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

def show
  @blog = Gluttonberg::Blog.published.first(:conditions => {:slug => params[:id]}, :include => [:articles])
  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