Class: NippoCore::ReportsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- NippoCore::ReportsController
- Includes:
- Pundit
- Defined in:
- app/controllers/nippo_core/reports_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
-
#index ⇒ Object
TODO: Implement test.
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/controllers/nippo_core/reports_controller.rb', line 21 def create @report if @report.save redirect_to group_reports_path(group_id: @group.id) else render 'new', status: 400 end end |
#edit ⇒ Object
30 31 32 33 |
# File 'app/controllers/nippo_core/reports_controller.rb', line 30 def edit @report render layout: nil end |
#index ⇒ Object
TODO: Implement test
8 9 10 11 |
# File 'app/controllers/nippo_core/reports_controller.rb', line 8 def index redirect_to home_path unless @group.member?(current_user) @reports = @group.reports.order(reported_at: :desc).page(params[:page]).per(10) end |
#new ⇒ Object
17 18 19 |
# File 'app/controllers/nippo_core/reports_controller.rb', line 17 def new @report end |
#show ⇒ Object
13 14 15 |
# File 'app/controllers/nippo_core/reports_controller.rb', line 13 def show @report end |
#update ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/controllers/nippo_core/reports_controller.rb', line 35 def update @report if @report.update(report_params) redirect_to [@group, @report] else head 400 end end |