Class: ActiveadminBlog::PostsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/activeadmin_blog/posts_controller.rb

Instance Method Summary collapse

Instance Method Details

#archiveObject



25
26
27
28
29
30
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 25

def archive
  month = params[:m].to_i
  year  = params[:y].to_i
  @posts = ActiveadminBlog::BlogPost.published_in_month(month, year)    
  @posts = @posts.page params[:page]
end

#categoryObject



19
20
21
22
23
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 19

def category
  category_slug = params[:slug]
  @posts = ActiveadminBlog::BlogPost.published_in_category(category_slug)
  @posts = @posts.page params[:page]
end

#feedObject



42
43
44
45
46
47
48
49
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 42

def feed
  @posts = ActiveadminBlog::BlogPost.published

  respond_to do |format|
    format.rss { render :layout => false } #index.rss.builder
    format.all { head :not_found }
  end
end

#indexObject



8
9
10
11
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 8

def index
  @posts = ActiveadminBlog::BlogPost.published
  @posts = @posts.page params[:page]
end

#load_categoriesObject



4
5
6
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 4

def load_categories
  @categories = ActiveadminBlog::BlogCategory.all
end

#searchObject



13
14
15
16
17
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 13

def search
  search_query  = params[:q]
  @posts = ActiveadminBlog::BlogPost.blog_search(search_query)
  @posts = @posts.page params[:page]
end

#showObject



38
39
40
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 38

def show
  @post = ActiveadminBlog::BlogPost.find_by(slug:params[:slug])
end

#tagObject



32
33
34
35
36
# File 'app/controllers/activeadmin_blog/posts_controller.rb', line 32

def tag
  tag = params[:tag]
  @posts = ActiveadminBlog::BlogPost.tagged_with(tag)
  @posts = @posts.page params[:page]
end