From ca98987c1a14655aedb4bdcf8fef7311131ca1be Mon Sep 17 00:00:00 2001 From: David Gay Date: Fri, 28 May 2021 21:23:38 -0400 Subject: Monsters controller, activities index, and links to activities and items indexes --- app/controllers/activities_controller.rb | 4 ++++ app/monsters_controller.rb | 9 +++++++++ app/views/activities/index.html.erb | 8 ++++++++ app/views/activities/show.html.erb | 2 +- app/views/application/_header.html.erb | 8 +++++++- app/views/monsters/index.html.erb | 8 ++++++++ app/views/monsters/show.html.erb | 12 ++++++++++++ config/routes.rb | 2 +- 8 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 app/monsters_controller.rb create mode 100644 app/views/activities/index.html.erb create mode 100644 app/views/monsters/index.html.erb create mode 100644 app/views/monsters/show.html.erb diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index 8e18ec9..2f9e9a5 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -1,4 +1,8 @@ class ActivitiesController < ApplicationController + def index + @activities = Activity.all.order(:name) + end + def show @activity = Activity.find(params[:id]) end diff --git a/app/monsters_controller.rb b/app/monsters_controller.rb new file mode 100644 index 0000000..4f947b3 --- /dev/null +++ b/app/monsters_controller.rb @@ -0,0 +1,9 @@ +class MonstersController < ApplicationController + def index + @monsters = Monster.all.order(:name) + end + + def show + @monster = Monster.find(params[:id]) + end +end diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb new file mode 100644 index 0000000..593adca --- /dev/null +++ b/app/views/activities/index.html.erb @@ -0,0 +1,8 @@ +

Activities

+ +<% @activities.each do |activity| %> +
+
<%= link_to activity.name, activity_path(activity) %>
+

<%= activity.description %>

+
+<% end %> diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb index 4516b51..50dbe4b 100644 --- a/app/views/activities/show.html.erb +++ b/app/views/activities/show.html.erb @@ -7,6 +7,6 @@ <% if @activity.whatnot %>
<%= JSON.pretty_generate(@activity.whatnot) %>
<% else %> -

Item has no additional data.

+

Activity has no additional data.

<% end %> diff --git a/app/views/application/_header.html.erb b/app/views/application/_header.html.erb index 6ca0671..25067f3 100644 --- a/app/views/application/_header.html.erb +++ b/app/views/application/_header.html.erb @@ -5,8 +5,14 @@
-