Class: BeetleReporter::ReportsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- BeetleReporter::ReportsController
- Defined in:
- app/controllers/beetle_reporter/reports_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #forbid ⇒ Object
- #hide ⇒ Object
- #ignore ⇒ Object
- #index ⇒ Object
- #mute ⇒ Object
- #new ⇒ Object
- #remove ⇒ Object
- #show ⇒ Object
- #suspend ⇒ Object
- #undo ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 23 def create # authorize Report create_params = report_params.to_hash.deep_symbolize_keys @report = report_scope.new(create_params) @report.user = current_user respond_to do |format| if @report.save format.turbo_stream { render turbo_stream: turbo_stream.replace(dom_id(@report), partial: "report", locals: {report: @report}) } format.html { redirect_to reports_path, notice: "report was successfully created." } else format.html { render :edit, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 59 def destroy # authorize @report @report.discard respond_to do |format| format.turbo_stream end end |
#edit ⇒ Object
40 41 42 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 40 def edit # authorize @report end |
#forbid ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 115 def forbid @report.beetle_forbid(params[:reason]) respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) } format.html { redirect_to reports_url, notice: 'report was successfully forbiden.' } end end |
#hide ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 87 def hide @report.beetle_hide(params[:reason]) respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) } format.html { redirect_to reports_url, notice: 'report was successfully hidden.' } end end |
#ignore ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 69 def ignore @report.ignore! respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) } format.html { redirect_to reports_url, notice: 'report was successfully ignored.' } end end |
#index ⇒ Object
5 6 7 8 9 10 11 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 5 def index # authorize Report load_reports # skip_policy_scope end |
#mute ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 105 def mute # TODO: 禁言时间 @report.beetle_mute(params[:reason]) respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) } format.html { redirect_to reports_url, notice: 'report was successfully muted.' } end end |
#new ⇒ Object
17 18 19 20 21 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 17 def new # authorize Report @report = Report.new end |
#remove ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 96 def remove @report.beetle_remove(params[:reason]) respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) } format.html { redirect_to reports_url, notice: 'report was successfully removed.' } end end |
#show ⇒ Object
13 14 15 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 13 def show # authorize @report end |
#suspend ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 78 def suspend @report.suspend! respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) } format.html { redirect_to reports_url, notice: 'report was successfully suspended.' } end end |
#undo ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 124 def undo @report.undo! respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.remove(dom_id(@report)) } format.html { redirect_to reports_url, notice: 'report was successfully undo.' } end end |
#update ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/beetle_reporter/reports_controller.rb', line 44 def update # authorize @report update_params = report_params.to_hash.deep_symbolize_keys respond_to do |format| if @report.update(update_params) format.turbo_stream { render turbo_stream: turbo_stream.replace(dom_id(@report), partial: "report", locals: {report: @report}) } format.html { redirect_to reports_path, notice: "report was successfully updated." } else format.html { render :edit, status: :unprocessable_entity } end end end |