Class: Commontator::ThreadsController

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

Instance Method Summary collapse

Instance Method Details

#closeObject

PUT /threads/1/close



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/commontator/threads_controller.rb', line 19

def close
  security_transgression_unless @thread.can_be_edited_by?(@user)

  @thread.errors.add(:base, t('commontator.thread.errors.already_closed')) \
    unless @thread.close(@user)

  @show_all = true

  respond_to do |format|
    format.html { redirect_to @thread }
    format.js { render :show }
  end
end

#reopenObject

PUT /threads/1/reopen



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/commontator/threads_controller.rb', line 34

def reopen
  security_transgression_unless @thread.can_be_edited_by?(@user)

  @thread.errors.add(:base, t('commontator.thread.errors.not_closed')) \
    unless @thread.reopen

  @show_all = true

  respond_to do |format|
    format.html { redirect_to @thread }
    format.js { render :show }
  end
end

#showObject

GET /threads/1



8
9
10
11
12
13
14
15
16
# File 'app/controllers/commontator/threads_controller.rb', line 8

def show
  commontator_thread_show(@thread.commontable)
  @show_all = params[:show_all] && @thread.can_be_edited_by?(@user)

  respond_to do |format|
    format.html { redirect_to main_app.polymorphic_path(@thread.commontable) }
    format.js
  end
end