This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it 'invalid without review_date' do | |
| card = build(:card, review_date: '') | |
| expect(card).to_not be_valid | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CheckTranslation | |
| include Interactor | |
| def call | |
| card = Card.find(context.id) | |
| if compare_text(card.original_text, context.user_text) | |
| card.update(review_date: 3.days.since) | |
| else | |
| context.text = card.original_text | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FlashcardsController < ApplicationController | |
| def index | |
| @card = Card.with_ready_date.random_one | |
| end | |
| def compare | |
| check_card = CheckTranslation.call(params) | |
| if check_card.text | |
| flash[:danger] = "Вы ответили неправильно, правильный ответ #{check_card.text}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scope :with_ready_date, -> { where('review_date <= ?', Date.today) } | |
| scope :random_one, -> { order('RANDOM()').first} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <p> | |
| Первый в мире удобный менеджер флеш-карточек. Именно так. | |
| </p> | |
| <h3><%= @card.translated_text %></h3> | |
| <%= form_tag root_path do %> | |
| <%= hidden_field_tag :original_text, @card.original_text %> | |
| <%= hidden_field_tag :id, @card.id %> | |
| <%= text_field_tag :user_text %> | |
| <%= button_tag %> | |
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Flashcard | |
| def initialize(original_text, user_text) | |
| @original_text = original_text | |
| @user_text = user_text | |
| end | |
| def compare | |
| compare_text(@original_text, @user_text) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FlashcardsController < ApplicationController | |
| def index | |
| @card = Card.with_ready_date.random_one | |
| end | |
| def compare | |
| @flashcard = Flashcard.new(params[:original_text], params[:user_text]) | |
| # user_card = Card.find(params[:id]) | |
| if @flashcard.compare |
NewerOlder