Class: Admin::InspectionDetailsController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::InspectionDetailsController
- Defined in:
- app/controllers/admin/inspection_details_controller.rb
Overview
Controller for managing inspection details.
Instance Method Summary collapse
-
#create ⇒ Object
POST /inspection_details POST /inspection_details.json Creates a new inspection detail.
-
#delete_all ⇒ Object
POST /inspection_details/delete_all Deletes multiple inspection details by their IDs.
-
#destroy ⇒ Object
DELETE /inspection_details/1 DELETE /inspection_details/1.json Deletes an existing inspection detail.
-
#edit ⇒ Object
GET /inspection_details/1/edit Displays a form for editing an inspection detail.
-
#index ⇒ Object
GET /inspection_details GET /inspection_details.json Displays a list of inspection details.
-
#new ⇒ Object
GET /inspection_details/new Displays a form for creating a new inspection detail.
-
#show ⇒ Object
GET /inspection_details/1 GET /inspection_details/1.json Displays the details of a specific inspection detail.
-
#update ⇒ Object
PATCH/PUT /inspection_details/1 PATCH/PUT /inspection_details/1.json Updates an existing inspection detail.
Instance Method Details
#create ⇒ Object
POST /inspection_details POST /inspection_details.json Creates a new inspection detail.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/admin/inspection_details_controller.rb', line 41 def create @inspection_detail = InspectionDetail.new( inspection_detail_params.merge(properties: properties_params, created_by_id: current_user.id) ) respond_to do |format| if @inspection_detail.save format.html { redirect_to admin_inspection_details_path, notice: 'Inspection detail was successfully created.' } format.json { render :show, status: :created, location: @inspection_detail } else format.html { render :new } format.json { render json: @inspection_detail.errors, status: :unprocessable_entity } end end end |
#delete_all ⇒ Object
POST /inspection_details/delete_all Deletes multiple inspection details by their IDs.
89 90 91 92 93 94 95 96 |
# File 'app/controllers/admin/inspection_details_controller.rb', line 89 def delete_all ids = params[:ids] InspectionDetail.where(id: ids).destroy_all respond_to do |format| format.html { redirect_to admin_inspection_details_path, notice: 'Inspection detail was successfully destroyed.' } format.json { render json: { message: 'Records deleted successfully' } } end end |
#destroy ⇒ Object
DELETE /inspection_details/1 DELETE /inspection_details/1.json Deletes an existing inspection detail.
78 79 80 81 82 83 84 85 |
# File 'app/controllers/admin/inspection_details_controller.rb', line 78 def destroy session[:destroy] ||= request.referer @inspection_detail.destroy respond_to do |format| format.html { redirect_to session.delete(:destroy), notice: 'Inspection detail was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /inspection_details/1/edit Displays a form for editing an inspection detail.
30 31 32 33 34 |
# File 'app/controllers/admin/inspection_details_controller.rb', line 30 def edit session[:edit] ||= request.referer @building = Building.find(@inspection_detail.building_id) if @inspection_detail.building_id @unit = Unit.find(@inspection_detail.unit_id) if @inspection_detail.unit_id end |
#index ⇒ Object
GET /inspection_details GET /inspection_details.json Displays a list of inspection details.
11 12 13 14 15 |
# File 'app/controllers/admin/inspection_details_controller.rb', line 11 def index @inspection_details = InspectionDetail.search(params[:property_id], params[:inspectable_item], params[:deficiency_definition],params[:comments],params[:location]).page params[:page] render action: :index, layout: request.xhr?.nil? end |
#new ⇒ Object
GET /inspection_details/new Displays a form for creating a new inspection detail.
24 25 26 |
# File 'app/controllers/admin/inspection_details_controller.rb', line 24 def new @inspection_detail = InspectionDetail.new end |
#show ⇒ Object
GET /inspection_details/1 GET /inspection_details/1.json Displays the details of a specific inspection detail.
20 |
# File 'app/controllers/admin/inspection_details_controller.rb', line 20 def show; end |
#update ⇒ Object
PATCH/PUT /inspection_details/1 PATCH/PUT /inspection_details/1.json Updates an existing inspection detail.
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/admin/inspection_details_controller.rb', line 62 def update respond_to do |format| if @inspection_detail.update(inspection_detail_params.merge(properties: properties_params, updated_by_id: current_user.id)) format.html { redirect_to session.delete(:edit), notice: 'Inspection detail was successfully updated.' } format.json { render :show, status: :ok, location: @inspection_detail } else format.html { render :edit } format.json { render json: @inspection_detail.errors, status: :unprocessable_entity } end end end |