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
# File 'app/controllers/commontator/threads_controller.rb', line 19

def close
  raise SecurityTransgression unless @thread.can_be_edited_by?(@user)

  @thread.errors.add(:base, 'This thread has already been closed.') \
    unless @thread.close(@user)

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

#reopenObject

PUT /threads/1/reopen



32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/commontator/threads_controller.rb', line 32

def reopen
  raise SecurityTransgression unless @thread.can_be_edited_by?(@user)

  @thread.errors.add(:base, 'This thread is not closed.') \
    unless @thread.reopen

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

#showObject

GET /threads/1



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

def show
  commontator_thread_show(@thread.commontable)

  respond_to do |format|
    format.html { redirect_to commontable_url }
    format.js
  end
end