Skip to content

Instantly share code, notes, and snippets.

@drymar
Created July 8, 2016 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drymar/232c4243d1fe21fb9d7a983eb5dca110 to your computer and use it in GitHub Desktop.
Save drymar/232c4243d1fe21fb9d7a983eb5dca110 to your computer and use it in GitHub Desktop.
class TicketsController < ApplicationController
respond_to? :js
def index
form = TicketFormValidator.new(form_params)
if form.valid?
@ticket = ticket_service(form.pnr_number)
@pnr = form.pnr_number
if @ticket.is_a? String
flash.now[:error] = @ticket
render 'shared/notice'
end
else
flash.now[:error] = 'Заполните пустые поля'
render 'shared/notice'
end
end
private
def form_params
params.permit(:provider, :pnr_number)
end
def ticket_service(pnr_number)
Kris::TicketRobotService.new.get_ticket(pnr_number)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment