Advertisement
VladikOtez

Controller

May 16th, 2017
1,150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.51 KB | None | 0 0
  1. class TrainerController < ApplicationController
  2.   before_action :find_card, only: [:review_card]
  3.   def index
  4.     @card = Card.needs_review.first
  5.   end
  6.   def review_card
  7.     correct_answer = @card.check_translation
  8.     if correct_answer
  9.       flash[:notice] =  "Correct"
  10.     else
  11.       flash[:error] = "Incorrect"
  12.     end
  13.     redirect_to trainer_index_path
  14.   end
  15.   private
  16.   def find_card
  17.     @card = Card.find(params[:card_id])
  18.   end
  19.   def trainer_params
  20.     params.permit(:translation)
  21.   end
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement