Add dictionary controller with index route

This commit is contained in:
maddiebaka 2023-10-12 20:02:22 -04:00
parent 6f46b1be7c
commit bbe677f201
5 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,5 @@
class DictionaryController < ApplicationController
def index
@parts_of_speech = PartOfSpeech.all
end
end

View File

@ -0,0 +1,2 @@
module DictionaryHelper
end

View File

@ -0,0 +1,2 @@
class PartOfSpeech < ApplicationRecord
end

View File

@ -0,0 +1,17 @@
<h1>Dictionary#index</h1>
<p>Find me in app/views/dictionary/index.html.erb</p>
<p><%= @parts_of_speech.count %> parts of speech entries in database</p>
<h1>Parts of Speech</h1>
<table>
<tr>
<td><b>Part of Speech</b></td>
<td><b>Definition</b></td>
</tr>
<% @parts_of_speech.each do |item| %>
<tr>
<td><%= item.pos %></td>
<td><%= item.definition %></td>
</tr>
<% end %>
</table>

View File

@ -1,4 +1,5 @@
Rails.application.routes.draw do Rails.application.routes.draw do
get 'dictionary/index'
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
@ -7,4 +8,5 @@ Rails.application.routes.draw do
# Defines the root path route ("/") # Defines the root path route ("/")
# root "posts#index" # root "posts#index"
root action: :index, controller: :dictionary
end end