Class: IshLibManager::ReportsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshLibManager::ReportsController
- Defined in:
- app/controllers/ish_lib_manager/reports_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#destroy ⇒ Object
26 27 28 29 30 31 |
# File 'app/controllers/ish_lib_manager/reports_controller.rb', line 26 def destroy @report = Report.unscoped.find params[:id] @report.is_trash = true @report.save redirect_to request.referrer end |
#edit ⇒ Object
22 23 24 |
# File 'app/controllers/ish_lib_manager/reports_controller.rb', line 22 def edit @report = Report.unscoped.find params[:id] end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/ish_lib_manager/reports_controller.rb', line 7 def index @reports = Report.unscoped.where( :is_trash => false ).page( params[:reports_page] ).per( Report::PER_PAGE ) if false === params[:site] @reports = @reports.where( :site_id => nil ) end if params[:site_id] @site = Site.find params[:site_id] @reports = @reports.where( :site_id => params[:site_id] ) end end |
#show ⇒ Object
18 19 20 |
# File 'app/controllers/ish_lib_manager/reports_controller.rb', line 18 def show @report = Report.unscoped.where({ :is_trash => false }).find params[:id] end |
#update ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/ish_lib_manager/reports_controller.rb', line 33 def update @report = Report.unscoped.find params[:id] :update, @report # photo photo = Photo.new photo.photo = params[:report][:photo] photo.report_id = @report.id photo.user = @report.user photo.is_public = @report.is_public photo.is_trash = false photo.save @report.photo = photo params[:report][:photo] = nil respond_to do |format| if @report.update_attributes(params[:report].permit( :name, :subhead, :descr, :venue, :city, :x, :y, :tag, :is_public, :photo, :site, :site_id )) format.html do redirect_to manager_report_path(@report), :notice => 'Report was successfully updated.' end format.json { head :ok } else format.html { render :action => "edit" } format.json { render :json => @report.errors, :status => :unprocessable_entity } end end end |