Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TrainerController < ApplicationController
- # before_action :find_card, only: [:review_card]
- def index
- @card = Card.needs_review.sample
- unless @card
- flash[:notice] = "Congrats. U solved add"
- redirect_to root_path
- end
- respond_to do |format|
- format.html
- format.js
- end
- end
- def review_card
- result = ReviewCard.call(
- translation: trainer_params[:translation]
- )
- @card = result.card
- if result.success?
- redirect_to trainer_index_path
- else
- redirect_to review_card_path(id: @card.id)
- end
- end
- protected
- # def find_card
- # @card = Card.find(params[:card_id])
- #end
- def trainer_params
- params.permit(:translation)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement