Class: DashboardController

Inherits:
ApplicationController show all
Defined in:
app/controllers/dashboard_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject


2
3
4
5
6
7
8
9
10
# File 'app/controllers/dashboard_controller.rb', line 2

def index
  authorize Post, :dashboard?

  gon.push(posts: {
             trash: stream_as_json(:trash),
             inbox: stream_as_json(:inbox),
             pulse: stream_as_json(:pulse)
           })
end

#stream_countObject


12
13
14
15
16
17
18
# File 'app/controllers/dashboard_controller.rb', line 12

def stream_count
  count = Post.where(stream: params[:stream]).count

  respond_to do |format|
    format.json { render json: { count: count } }
  end
end

#update_postObject


20
21
22
23
24
25
26
27
28
# File 'app/controllers/dashboard_controller.rb', line 20

def update_post
  @post = Post.find params[:id]
  authorize @post, :dashboard?
  @post.update_attribute :stream, params[:post][:stream]

  respond_to do |format|
    format.json { render json: @post }
  end
end