-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: opponent team + cloudinary storage
- Loading branch information
1 parent
6305cc4
commit e61d179
Showing
47 changed files
with
630 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
class HallOfFamesController < ApplicationController | ||
before_action :set_hall_of_fame, only: %i[ show edit update destroy ] | ||
|
||
# GET /hall_of_fames or /hall_of_fames.json | ||
def index | ||
@hall_of_fames = HallOfFame.all | ||
end | ||
|
||
# GET /hall_of_fames/1 or /hall_of_fames/1.json | ||
def show | ||
end | ||
|
||
# GET /hall_of_fames/new | ||
def new | ||
@hall_of_fame = HallOfFame.new | ||
end | ||
|
||
# GET /hall_of_fames/1/edit | ||
def edit | ||
end | ||
|
||
# POST /hall_of_fames or /hall_of_fames.json | ||
def create | ||
@hall_of_fame = HallOfFame.new(hall_of_fame_params) | ||
|
||
respond_to do |format| | ||
if @hall_of_fame.save | ||
format.html { redirect_to hall_of_fame_url(@hall_of_fame), notice: "Hall of fame was successfully created." } | ||
format.json { render :show, status: :created, location: @hall_of_fame } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @hall_of_fame.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /hall_of_fames/1 or /hall_of_fames/1.json | ||
def update | ||
respond_to do |format| | ||
if @hall_of_fame.update(hall_of_fame_params) | ||
format.html { redirect_to hall_of_fame_url(@hall_of_fame), notice: "Hall of fame was successfully updated." } | ||
format.json { render :show, status: :ok, location: @hall_of_fame } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @hall_of_fame.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /hall_of_fames/1 or /hall_of_fames/1.json | ||
def destroy | ||
@hall_of_fame.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to hall_of_fames_url, notice: "Hall of fame was successfully destroyed." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_hall_of_fame | ||
@hall_of_fame = HallOfFame.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def hall_of_fame_params | ||
params.require(:hall_of_fame).permit(:team_id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
class OpponentTeamsController < ApplicationController | ||
before_action :set_opponent_team, only: %i[ show edit update destroy ] | ||
|
||
# GET /opponent_teams or /opponent_teams.json | ||
def index | ||
@opponent_teams = OpponentTeam.all | ||
end | ||
|
||
# GET /opponent_teams/1 or /opponent_teams/1.json | ||
def show | ||
end | ||
|
||
# GET /opponent_teams/new | ||
def new | ||
@opponent_team = OpponentTeam.new | ||
end | ||
|
||
# GET /opponent_teams/1/edit | ||
def edit | ||
end | ||
|
||
# POST /opponent_teams or /opponent_teams.json | ||
def create | ||
@opponent_team = OpponentTeam.new(opponent_team_params) | ||
|
||
respond_to do |format| | ||
if @opponent_team.save | ||
format.html { redirect_to opponent_team_url(@opponent_team), notice: "Opponent team was successfully created." } | ||
format.json { render :show, status: :created, location: @opponent_team } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @opponent_team.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /opponent_teams/1 or /opponent_teams/1.json | ||
def update | ||
respond_to do |format| | ||
if @opponent_team.update(opponent_team_params) | ||
format.html { redirect_to opponent_team_url(@opponent_team), notice: "Opponent team was successfully updated." } | ||
format.json { render :show, status: :ok, location: @opponent_team } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @opponent_team.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /opponent_teams/1 or /opponent_teams/1.json | ||
def destroy | ||
@opponent_team.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to opponent_teams_url, notice: "Opponent team was successfully destroyed." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_opponent_team | ||
@opponent_team = OpponentTeam.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def opponent_team_params | ||
params.require(:opponent_team).permit(:name, :team_url, :team_badge) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module HallOfFamesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module OpponentTeamsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class HallOfFame < ApplicationRecord | ||
belongs_to :team | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
class Opponent < ApplicationRecord | ||
belongs_to :user | ||
belongs_to :opponent_team | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class OpponentTeam < ApplicationRecord | ||
has_one_attached :team_badge | ||
|
||
validates :name, presence: true | ||
validates :team_badge, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<%= form_with(model: hall_of_fame, class: "contents") do |form| %> | ||
<% if hall_of_fame.errors.any? %> | ||
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3"> | ||
<h2><%= pluralize(hall_of_fame.errors.count, "error") %> prohibited this hall_of_fame from being saved:</h2> | ||
|
||
<ul> | ||
<% hall_of_fame.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="my-5"> | ||
<%= form.label :team_id %> | ||
<%= form.text_field :team_id, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %> | ||
</div> | ||
|
||
<div class="inline"> | ||
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div id="<%= dom_id hall_of_fame %>"> | ||
<p class="my-5"> | ||
<strong class="block font-medium mb-1">Team:</strong> | ||
<%= hall_of_fame.team_id %> | ||
</p> | ||
|
||
<% if action_name != "show" %> | ||
<%= link_to "Show this hall of fame", hall_of_fame, class: "rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> | ||
<%= link_to "Edit this hall of fame", edit_hall_of_fame_path(hall_of_fame), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %> | ||
<hr class="mt-6"> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! hall_of_fame, :id, :team_id, :created_at, :updated_at | ||
json.url hall_of_fame_url(hall_of_fame, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="mx-auto md:w-2/3 w-full"> | ||
<h1 class="font-bold text-4xl">Editing hall of fame</h1> | ||
|
||
<%= render "form", hall_of_fame: @hall_of_fame %> | ||
<%= link_to "Show this hall of fame", @hall_of_fame, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> | ||
<%= link_to "Back to hall of fames", hall_of_fames_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div class="w-full"> | ||
<% if notice.present? %> | ||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p> | ||
<% end %> | ||
|
||
<div class="flex justify-between items-center"> | ||
<h1 class="font-bold text-4xl">Hall of fames</h1> | ||
<%= link_to "New hall of fame", new_hall_of_fame_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %> | ||
</div> | ||
|
||
<div id="hall_of_fames" class="min-w-full"> | ||
<%= render @hall_of_fames %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @hall_of_fames, partial: "hall_of_fames/hall_of_fame", as: :hall_of_fame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="mx-auto md:w-2/3 w-full"> | ||
<h1 class="font-bold text-4xl">New hall of fame</h1> | ||
|
||
<%= render "form", hall_of_fame: @hall_of_fame %> | ||
<%= link_to "Back to hall of fames", hall_of_fames_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="mx-auto md:w-2/3 w-full flex"> | ||
<div class="mx-auto"> | ||
<% if notice.present? %> | ||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p> | ||
<% end %> | ||
<%= render @hall_of_fame %> | ||
<%= link_to "Edit this hall_of_fame", edit_hall_of_fame_path(@hall_of_fame), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> | ||
<div class="inline-block ml-2"> | ||
<%= button_to "Destroy this hall_of_fame", hall_of_fame_path(@hall_of_fame), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %> | ||
</div> | ||
<%= link_to "Back to hall_of_fames", hall_of_fames_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "hall_of_fames/hall_of_fame", hall_of_fame: @hall_of_fame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<%= form_with(model: opponent_team, class: "contents") do |form| %> | ||
<% if opponent_team.errors.any? %> | ||
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3"> | ||
<h2><%= pluralize(opponent_team.errors.count, "error") %> prohibited this opponent_team from being saved:</h2> | ||
|
||
<ul> | ||
<% opponent_team.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="my-5"> | ||
<%= form.label :name %> | ||
<%= form.text_field :name, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %> | ||
</div> | ||
|
||
<div class="my-5"> | ||
<%= form.label :team_url %> | ||
<%= form.text_field :team_url, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %> | ||
</div> | ||
|
||
<div class="my-5"> | ||
<%= form.label :team_badge %> | ||
<%= form.file_field :team_badge, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %> | ||
</div> | ||
|
||
<div class="inline"> | ||
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> | ||
</div> | ||
<% end %> |
Oops, something went wrong.