Rubocop rules
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
class ReservationsController < ApplicationController
|
||||
before_action :set_company
|
||||
before_action :set_reservation, only: %i[ show edit update destroy ]
|
||||
before_action :set_reservation, only: %i[show edit update destroy]
|
||||
|
||||
layout :determine_layout
|
||||
# GET /reservations or /reservations.json
|
||||
def index
|
||||
@reservations = Reservation.all.includes(:team, :customer).where(company: @company)
|
||||
@reservations = Reservation.includes(:team, :customer).where(company: @company)
|
||||
@reservations = ActiveModelSerializers::SerializableResource.new(@reservations).as_json
|
||||
end
|
||||
|
||||
# GET /reservations/1 or /reservations/1.json
|
||||
def show
|
||||
end
|
||||
def show; end
|
||||
|
||||
# GET /reservations/new
|
||||
def new
|
||||
@@ -20,8 +19,7 @@ class ReservationsController < ApplicationController
|
||||
end
|
||||
|
||||
# GET /reservations/1/edit
|
||||
def edit
|
||||
end
|
||||
def edit; end
|
||||
|
||||
# POST /reservations or /reservations.json
|
||||
def create
|
||||
@@ -30,7 +28,7 @@ class ReservationsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @reservation.save
|
||||
format.html { redirect_to reservation_url(@reservation), notice: "Reservation was successfully created." }
|
||||
format.html { redirect_to reservation_url(@reservation), notice: t('.reservation_created') }
|
||||
format.json { render :show, status: :created, location: @reservation }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
@@ -43,7 +41,7 @@ class ReservationsController < ApplicationController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @reservation.update(reservation_params)
|
||||
format.html { redirect_to reservation_url(@reservation), notice: "Reservation was successfully updated." }
|
||||
format.html { redirect_to reservation_url(@reservation), notice: t('.reservation_updated') }
|
||||
format.json { render :show, status: :ok, location: @reservation }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
@@ -57,24 +55,25 @@ class ReservationsController < ApplicationController
|
||||
@reservation.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to reservations_url, notice: "Reservation was successfully destroyed." }
|
||||
format.html { redirect_to reservations_url, notice: t('.reservation_destroyed') }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_reservation
|
||||
@reservation = Reservation.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def reservation_params
|
||||
params.require(:reservation).permit(:company_id, :customer_id, :team_id, :title, :description, :start_time, :end_time)
|
||||
end
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_reservation
|
||||
@reservation = Reservation.find(params[:id])
|
||||
end
|
||||
|
||||
def determine_layout
|
||||
action_name == 'index' ? 'calendar' : 'application'
|
||||
end
|
||||
# Only allow a list of trusted parameters through.
|
||||
def reservation_params
|
||||
params.require(:reservation).permit(:company_id, :customer_id, :team_id, :title, :description, :start_time,
|
||||
:end_time)
|
||||
end
|
||||
|
||||
def determine_layout
|
||||
action_name == 'index' ? 'calendar' : 'application'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user