diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/blog_posts_controller.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/app/controllers/blog_posts_controller.rb b/app/controllers/blog_posts_controller.rb index 95169c0..7ddb7b8 100644 --- a/app/controllers/blog_posts_controller.rb +++ b/app/controllers/blog_posts_controller.rb @@ -1,6 +1,6 @@ class BlogPostsController < ApplicationController - before_filter :find_all_blog_posts + before_filter :find_all_blog_posts, :find_all_blog_categories before_filter :find_page def index @@ -20,11 +20,23 @@ class BlogPostsController < ApplicationController protected def find_all_blog_posts - @blog_posts = BlogPost.live + unless params[:category_id].present? + @blog_posts = BlogPost.live + else + if (category = BlogCategory.find(params[:category_id])).present? + @blog_posts = category.posts + else + error_404 + end + end + end + + def find_all_blog_categories + @blog_categories = BlogCategory.all end def find_page - @page = Page.find_by_link_url("/blogs") + @page = Page.find_by_link_url("/blog") end end |