Class: BlogsController
- Inherits:
-
InheritedResources::Base
- Object
- InheritedResources::Base
- BlogsController
- Defined in:
- app/controllers/blogs_controller.rb
Instance Method Summary collapse
- #collection ⇒ Object
- #load_maybe ⇒ Object
- #maybe_authenticate ⇒ Object
- #parent ⇒ Object
- #tags ⇒ Object
Instance Method Details
#collection ⇒ Object
23 24 25 26 |
# File 'app/controllers/blogs_controller.rb', line 23 def collection @blogs ||= Blog.where(:user_id=>parent.id). paginate(:page => params[:page], :order => 'created_at DESC' ) end |
#load_maybe ⇒ Object
9 10 11 12 13 |
# File 'app/controllers/blogs_controller.rb', line 9 def load_maybe unless params[:user_id] @user = (current_user || User.root) end end |
#maybe_authenticate ⇒ Object
33 34 35 36 37 |
# File 'app/controllers/blogs_controller.rb', line 33 def maybe_authenticate unless user_signed_in? authenticate_user! unless current_ability.can? :read, resource end end |
#parent ⇒ Object
15 16 17 |
# File 'app/controllers/blogs_controller.rb', line 15 def parent @user ||= User.find(params[:user_id]) end |
#tags ⇒ Object
19 20 21 |
# File 'app/controllers/blogs_controller.rb', line 19 def @tags ||= Blog.where(:user_id=>parent.id).tag_counts.sort{|t, u| t.count <=> u.count} end |