Class: MongoidForums::Admin::TopicsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/mongoid_forums/admin/topics_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject



6
7
# File 'app/controllers/mongoid_forums/admin/topics_controller.rb', line 6

def edit
end

#toggle_hideObject



24
25
26
27
28
# File 'app/controllers/mongoid_forums/admin/topics_controller.rb', line 24

def toggle_hide
  @topic.toggle!(:hidden)
  flash[:notice] = t("mongoid_forums.topic.hidden.#{@topic.hidden?}")
  redirect_to topic_path(@topic)
end

#toggle_lockObject



30
31
32
33
34
# File 'app/controllers/mongoid_forums/admin/topics_controller.rb', line 30

def toggle_lock
  @topic.toggle!(:locked)
  flash[:notice] = t("mongoid_forums.topic.locked.#{@topic.locked?}")
  redirect_to topic_path(@topic)
end

#toggle_pinObject



36
37
38
39
40
# File 'app/controllers/mongoid_forums/admin/topics_controller.rb', line 36

def toggle_pin
  @topic.toggle!(:pinned)
  flash[:notice] = t("mongoid_forums.topic.pinned.#{@topic.pinned?}")
  redirect_to topic_path(@topic)
end

#updateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/mongoid_forums/admin/topics_controller.rb', line 9

def update
  @topic.subject  = params[:topic][:subject]
  @topic.pinned   = params[:topic][:pinned]
  @topic.locked   = params[:topic][:locked]
  @topic.hidden   = params[:topic][:hidden]
  @topic.forum_id = params[:topic][:forum_id]
  if @topic.save
    flash[:notice] = t("mongoid_forums.topic.updated")
    redirect_to topic_path(@topic)
  else
    flash.alert = t("mongoid_forums.topic.not_updated")
    render :action => "edit"
  end
end