Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ReviewCard
- include Interactor
- def call
- id = context.id
- translation = context.translation
- card = Card.find(id)
- answer = card.check_translation translation
- answer ? context.message = 'Correct' :
- context.message = 'Incorrect'
- end
- end
- --------------------------------------------------------------------------
- def review_card
- result = ReviewCard.call(
- id: params[:card_id],
- translation: trainer_params[:translation]
- )
- @card = result.card
- if result.success?
- @card.refresh_review_date
- redirect_back
- else
- redirect_to trainer_index_path
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement