Class: ReviewsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/reviews_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#not_authenticated, #set_locale

Instance Method Details

#createObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/reviews_controller.rb', line 6

def create
  @card = current_user.cards.find(review_params[:card_id])
  review = @card.review(review_params[:answer])

  if review[:success]
    flash[:success] = t("review_success",
                        original: @card.original_text,
                        translated: @card.translated_text,
                        user_answer: review_params[:answer],
                        typos: review[:typos],
                        next: @card.review_date.localtime
                       )
  else
    flash[:danger] = "#{t('review_wrong', next_review: @card.review_date)}"
  end
  redirect_to new_review_path
end

#newObject


2
3
4
# File 'app/controllers/reviews_controller.rb', line 2

def new
  @card = current_user.cards_for_review.first
end