Commit placeholder work

This commit is contained in:
maddiebaka
2023-12-06 15:53:25 -05:00
parent 60f37ece67
commit 709aa882b3
8 changed files with 56 additions and 3 deletions

View File

@@ -1,6 +1,12 @@
class DictionaryController < ApplicationController
def index
@parts_of_speech = PartOfSpeech.all
@english = Language.where(name: "English")
@parts_of_speech = PartOfSpeech.where(language_id: @english)
@parts_of_speech.each do |pos|
pos.translations.build
end
@words = Word.all
end

View File

@@ -1,3 +1,5 @@
class PartOfSpeech < ApplicationRecord
belongs_to :language
has_many :translations, class_name: "PartOfSpeech", foreign_key: "part_of_speech_id"
end

View File

@@ -4,11 +4,17 @@
<tr>
<td><b>Part of Speech</b></td>
<td><b>Definition</b></td>
<% unless current_user.blank? %>
<td><b>Translation</b></td>
<% end %>
</tr>
<% parts_of_speech.each do |item| %>
<tr>
<td><b><%= item.pos %></b></td>
<td><%= item.definition %></td>
<% unless current_user.blank? %>
<td><%= item.translations.first.definition %></td>
<% end %>
</tr>
<% end %>
</table>