From bbe677f201032e8825ba90af65b9e51dd2e22511 Mon Sep 17 00:00:00 2001 From: maddiebaka Date: Thu, 12 Oct 2023 20:02:22 -0400 Subject: [PATCH] Add dictionary controller with index route --- app/controllers/dictionary_controller.rb | 5 +++++ app/helpers/dictionary_helper.rb | 2 ++ app/models/part_of_speech.rb | 2 ++ app/views/dictionary/index.html.erb | 17 +++++++++++++++++ config/routes.rb | 2 ++ 5 files changed, 28 insertions(+) create mode 100644 app/controllers/dictionary_controller.rb create mode 100644 app/helpers/dictionary_helper.rb create mode 100644 app/models/part_of_speech.rb create mode 100644 app/views/dictionary/index.html.erb diff --git a/app/controllers/dictionary_controller.rb b/app/controllers/dictionary_controller.rb new file mode 100644 index 0000000..1c164c5 --- /dev/null +++ b/app/controllers/dictionary_controller.rb @@ -0,0 +1,5 @@ +class DictionaryController < ApplicationController + def index + @parts_of_speech = PartOfSpeech.all + end +end diff --git a/app/helpers/dictionary_helper.rb b/app/helpers/dictionary_helper.rb new file mode 100644 index 0000000..e147a98 --- /dev/null +++ b/app/helpers/dictionary_helper.rb @@ -0,0 +1,2 @@ +module DictionaryHelper +end diff --git a/app/models/part_of_speech.rb b/app/models/part_of_speech.rb new file mode 100644 index 0000000..a06a03d --- /dev/null +++ b/app/models/part_of_speech.rb @@ -0,0 +1,2 @@ +class PartOfSpeech < ApplicationRecord +end diff --git a/app/views/dictionary/index.html.erb b/app/views/dictionary/index.html.erb new file mode 100644 index 0000000..0b6bae0 --- /dev/null +++ b/app/views/dictionary/index.html.erb @@ -0,0 +1,17 @@ +

Dictionary#index

+

Find me in app/views/dictionary/index.html.erb

+ +

<%= @parts_of_speech.count %> parts of speech entries in database

+

Parts of Speech

+ + + + + +<% @parts_of_speech.each do |item| %> + + + + +<% end %> +
Part of SpeechDefinition
<%= item.pos %><%= item.definition %>
diff --git a/config/routes.rb b/config/routes.rb index a125ef0..e64210b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do + get 'dictionary/index' # 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. @@ -7,4 +8,5 @@ Rails.application.routes.draw do # Defines the root path route ("/") # root "posts#index" + root action: :index, controller: :dictionary end