Skip to content

Instantly share code, notes, and snippets.

@stephenrichards
Created December 12, 2018 10:22
Show Gist options
  • Save stephenrichards/5dc852a793c4b5bc18bb354c3426ed8c to your computer and use it in GitHub Desktop.
Save stephenrichards/5dc852a793c4b5bc18bb354c3426ed8c to your computer and use it in GitHub Desktop.
Thin Controller
class ThinController < ApplicationController
def index
@cards = OysterCard.order(balance: :desc)
end
def show
end
def swipe_out
@card = OysteCard.find(params[:id])
authorize @card # uses a Pundit policy to determine whether or not the current user is authorised to update this card
@card.record_swipe_out(params[:swipe_out][journey_end_station_id)
if @card.alert_messages.any?
flash[:alert] = @card.alert_messages
end
redirect_to card_show_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment