Class: Commontator::ThreadsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Commontator::ThreadsController
- Defined in:
- app/controllers/commontator/threads_controller.rb
Instance Method Summary collapse
-
#close ⇒ Object
PUT /threads/1/close.
-
#mentions ⇒ Object
GET /threads/1/mentions.json.
-
#reopen ⇒ Object
PUT /threads/1/reopen.
-
#show ⇒ Object
GET /threads/1.
Instance Method Details
#close ⇒ Object
PUT /threads/1/close
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/commontator/threads_controller.rb', line 18 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 |
#mentions ⇒ Object
GET /threads/1/mentions.json
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/commontator/threads_controller.rb', line 48 def mentions security_transgression_unless @thread.can_be_read_by?(@user) && Commontator.mentions_enabled query = params[:q].to_s if query.size < 3 render json: { errors: ['Query string is too short (minimum 3 characters)'] }, status: :unprocessable_entity else render json: serialized_mentions(query) end end |
#reopen ⇒ Object
PUT /threads/1/reopen
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/commontator/threads_controller.rb', line 33 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 |
#show ⇒ Object
GET /threads/1
7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/commontator/threads_controller.rb', line 7 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 |