Order guests by affinity group
This commit is contained in:
parent
204771ef2b
commit
8732dac0a3
@ -1,14 +1,16 @@
|
|||||||
class GuestsController < ApplicationController
|
class GuestsController < ApplicationController
|
||||||
before_action :set_guest, only: %i[ show edit update destroy ]
|
before_action :set_guest, only: %i[show edit update destroy]
|
||||||
|
|
||||||
# GET /guests or /guests.json
|
# GET /guests or /guests.json
|
||||||
def index
|
def index
|
||||||
@guests = Guest.all.includes(:affinity_groups, :unbreakable_bonds)
|
@guests = Guest.all
|
||||||
|
.left_outer_joins(:affinity_groups)
|
||||||
|
.order('tags.name' => :asc)
|
||||||
|
.includes(:affinity_groups, :unbreakable_bonds)
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /guests/1 or /guests/1.json
|
# GET /guests/1 or /guests/1.json
|
||||||
def show
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
# GET /guests/new
|
# GET /guests/new
|
||||||
def new
|
def new
|
||||||
@ -16,8 +18,7 @@ class GuestsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
# GET /guests/1/edit
|
# GET /guests/1/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# POST /guests or /guests.json
|
# POST /guests or /guests.json
|
||||||
def create
|
def create
|
||||||
@ -25,7 +26,7 @@ class GuestsController < ApplicationController
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @guest.save
|
if @guest.save
|
||||||
format.html { redirect_to guest_url(@guest), notice: "Guest was successfully created." }
|
format.html { redirect_to guest_url(@guest), notice: 'Guest was successfully created.' }
|
||||||
format.json { render :show, status: :created, location: @guest }
|
format.json { render :show, status: :created, location: @guest }
|
||||||
else
|
else
|
||||||
format.html { render :new, status: :unprocessable_entity }
|
format.html { render :new, status: :unprocessable_entity }
|
||||||
@ -38,7 +39,7 @@ class GuestsController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @guest.update(guest_params)
|
if @guest.update(guest_params)
|
||||||
format.html { redirect_to guest_url(@guest), notice: "Guest was successfully updated." }
|
format.html { redirect_to guest_url(@guest), notice: 'Guest was successfully updated.' }
|
||||||
format.json { render :show, status: :ok, location: @guest }
|
format.json { render :show, status: :ok, location: @guest }
|
||||||
else
|
else
|
||||||
format.html { render :edit, status: :unprocessable_entity }
|
format.html { render :edit, status: :unprocessable_entity }
|
||||||
@ -52,12 +53,13 @@ class GuestsController < ApplicationController
|
|||||||
@guest.destroy!
|
@guest.destroy!
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to guests_url, notice: "Guest was successfully destroyed." }
|
format.html { redirect_to guests_url, notice: 'Guest was successfully destroyed.' }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_guest
|
def set_guest
|
||||||
@guest = Guest.find(params[:id])
|
@guest = Guest.find(params[:id])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user