diff options
-rw-r--r-- | app/controllers/locations_controller.rb | 9 | ||||
-rw-r--r-- | app/models/location.rb | 1 | ||||
-rw-r--r-- | app/views/application/_navbar.html.erb | 2 | ||||
-rw-r--r-- | app/views/locations/index.html.erb | 8 | ||||
-rw-r--r-- | app/views/locations/show.html.erb | 7 | ||||
-rw-r--r-- | config/routes.rb | 2 |
6 files changed, 28 insertions, 1 deletions
diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb new file mode 100644 index 0000000..4616c3d --- /dev/null +++ b/app/controllers/locations_controller.rb @@ -0,0 +1,9 @@ +class LocationsController < ApplicationController + def index + @locations = Location.all + end + + def show + @location = Location.find(params[:id]) + end +end diff --git a/app/models/location.rb b/app/models/location.rb index 8816274..e35e5e7 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,3 +1,4 @@ class Location < ApplicationRecord + has_many :activities validates :gid, :name, presence: true end diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb index 85f4642..104c349 100644 --- a/app/views/application/_navbar.html.erb +++ b/app/views/application/_navbar.html.erb @@ -1,7 +1,7 @@ <ul class="py-2 px-2 col-span-12 text-display"> <% if current_char %> <li class="mr-6 inline"> - Actions + <%= link_to "Locations", locations_path %> </li> <li class="mr-6 inline"> <%= link_to "Character", character_path(current_char) %> diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb new file mode 100644 index 0000000..758fd35 --- /dev/null +++ b/app/views/locations/index.html.erb @@ -0,0 +1,8 @@ +<h1 class="text-xl">Locations</h1> + +<ul> + <% @locations.each do |location| %> + <li><span class="font-bold"><%= link_to location.name, location_path(location) %></span> + – <%= location.description %></li> + <% end %> +</ul> diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb new file mode 100644 index 0000000..c3a75e1 --- /dev/null +++ b/app/views/locations/show.html.erb @@ -0,0 +1,7 @@ +<h1 class="text-xl"><%= @location.name %></h1> + +<ul> + <% @location.activities.each do |activity| %> + <li><span class="font-bold"><%= link_to activity.name, "#" %></span> – <%= activity.description %></li> + <% end %> +</ul> diff --git a/config/routes.rb b/config/routes.rb index bd5793e..6442ec2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,4 +16,6 @@ Rails.application.routes.draw do resources :items, only: [:index] end end + + resources :locations, only: [:index, :show] end |