Class: Discussion::ThreadsController

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

Instance Method Summary collapse

Instance Method Details

#createObject


36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/discussion/threads_controller.rb', line 36

def create
  build_resource
  respond_to do |format|
    if @thread.save
      mark_thread_as_read
      format.html { redirect_to_list }
      format.js { collection }
      format.json { render json: @thread, status: :created, location: @thread }
    else
      format.html { render action: "new" }
      format.json { render json: @thread.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject


63
64
65
66
67
68
69
70
# File 'app/controllers/discussion/threads_controller.rb', line 63

def destroy
  @thread.destroy
  respond_to do |format|
    format.html { redirect_to_list }
    format.js { collection }
    format.json { head :no_content }
  end
end

#editObject


33
34
# File 'app/controllers/discussion/threads_controller.rb', line 33

def edit
end

#indexObject


11
12
13
14
# File 'app/controllers/discussion/threads_controller.rb', line 11

def index
  @threads = collection
  respond_with(@threads)
end

#listObject


16
17
18
19
# File 'app/controllers/discussion/threads_controller.rb', line 16

def list
  @threads = collection
  respond_with(@threads)
end

#newObject


28
29
30
31
# File 'app/controllers/discussion/threads_controller.rb', line 28

def new
  build_resource
  respond_with(@thread)
end

#showObject


21
22
23
24
25
26
# File 'app/controllers/discussion/threads_controller.rb', line 21

def show
  mark_thread_as_read
  mark_all_thread_comments_as_read

  respond_with(@thread)
end

#updateObject


51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/discussion/threads_controller.rb', line 51

def update
  respond_to do |format|
    if @thread.update_attributes(params[:thread])
      format.html { redirect_to @thread, notice: 'Thread was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @thread.errors, status: :unprocessable_entity }
    end
  end
end