Class: K3cms::Blog::BlogPostsCell
- Inherits:
-
Cell::Rails
- Object
- Cell::Rails
- K3cms::Blog::BlogPostsCell
- Defined in:
- app/cells/k3cms/blog/blog_posts_cell.rb
Instance Method Summary collapse
-
#current_ability ⇒ Object
Sorry this is duplicated between here and app/controllers/k3cms/blog/base_controller.rb I tried refactoring the common code out to a BaseControllerModule module that got mixed in both places, but for whatever reason that I couldn’t figure out, it would use the current_ability defined in cancan/lib/cancan/controller_additions.rb:277: def current_ability @current_ability ||= ::Ability.new(current_user) end which references non-existent Ability class.
- #index ⇒ Object
- #metadata_drawer ⇒ Object
- #published_status ⇒ Object
Instance Method Details
#current_ability ⇒ Object
Sorry this is duplicated between here and app/controllers/k3cms/blog/base_controller.rb I tried refactoring the common code out to a BaseControllerModule module that got mixed in both places, but for whatever reason that I couldn’t figure out, it would use the current_ability defined in cancan/lib/cancan/controller_additions.rb:277:
def current_ability
@current_ability ||= ::Ability.new(current_user)
end
which references non-existent Ability class.
14 15 16 |
# File 'app/cells/k3cms/blog/blog_posts_cell.rb', line 14 def current_ability @current_ability ||= K3cms::Blog::Ability.new(k3cms_user) end |
#index ⇒ Object
22 23 24 25 26 27 |
# File 'app/cells/k3cms/blog/blog_posts_cell.rb', line 22 def index @blog_posts = BlogPost.accessible_by(current_ability).order('id desc') # This is to enforce the blog_post.published? condition specified in a block. accessible_by doesn't automatically check the block conditions when fetching records. @blog_posts.select! {|blog_post| can?(:read, blog_post)} render end |
#metadata_drawer ⇒ Object
29 30 31 32 |
# File 'app/cells/k3cms/blog/blog_posts_cell.rb', line 29 def @blog_post = [:blog_post] render end |
#published_status ⇒ Object
18 19 20 |
# File 'app/cells/k3cms/blog/blog_posts_cell.rb', line 18 def published_status render end |