Read-only patch written, frontend shows dictionary in different languages

This commit is contained in:
maddiebaka
2023-12-07 11:31:54 -05:00
parent 60f37ece67
commit 937f97ecb2
23 changed files with 3364 additions and 264 deletions

View File

@@ -3,6 +3,7 @@ class ActiveLanguageController < ApplicationController
def set_active_language
if Language.find_by_id(params[:active_language_id]) != nil
cookies[:active_language_id] = params[:active_language_id]
redirect_back fallback_location: root_path
else
redirect_to root_path, status: :unprocessable_entity
end

View File

@@ -1,11 +1,19 @@
class DictionaryController < ApplicationController
def index
@parts_of_speech = PartOfSpeech.all
@parts_of_speech = PartOfSpeech.where(language_id: active_language)
@words = Word.all
end
def show
@letter = params[:id]
@words = Word.where('substr(word, 1, 1) = ?', @letter)
@language = active_language
#@words.joins(:definitions).where(definitions: { language_id: active_language })
end
private
def active_language
cookies[:active_language_id] || Language.where(name: "English")
end
end