Class: Effective::PostsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Effective::PostsController
- Defined in:
- app/controllers/effective/posts_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/effective/posts_controller.rb', line 7 def index @posts = (Rails::VERSION::MAJOR > 3 ? Effective::Post.all : Effective::Post.scoped) @posts = @posts.for_role(current_user.try(:roles)) if defined?(EffectiveRoles) @posts = @posts.with_category(params[:category]) if params[:category] @posts = @posts.published @posts = @posts.includes(:regions) @posts = @posts.order("#{EffectivePosts.posts_table_name}.published_at DESC") @posts = @posts.page(params[:page]).per(EffectivePosts.per_page) EffectivePosts.(self, :index, Effective::Post) @page_title = (params[:category] || 'Posts').titleize end |
#show ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/effective/posts_controller.rb', line 23 def show @posts = (Rails::VERSION::MAJOR > 3 ? Effective::Post.all : Effective::Post.scoped) @posts = @posts.with_category(params[:category]) if params[:category] @posts = @posts.published if params[:edit].to_s != 'true' @posts = @posts.includes(:regions) @post = @posts.find(params[:id]) if defined?(EffectiveRoles) raise Effective::AccessDenied unless @post.roles_permit?(current_user) end EffectivePosts.(self, :show, @post) @page_title = @post.title end |