Quiz 2 updated

parent bfcd5dc0
......@@ -163,3 +163,6 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
web-console (~> 2.0)
BUNDLED WITH
1.10.4
class WeaponsController < ApplicationController
def index
@weapons = Weapon.all
if params[:q].present?
@weapons = Weapon.where(name: params[:q])
end
render "weapons/index.html.erb"
end
......@@ -38,16 +33,15 @@ class WeaponsController < ApplicationController
end
end
def show
def destroy
@weapon = Weapon.find(params[:id])
render "weapons/show.html.erb"
@weapon.destroy!
redirect_to weapons_path
end
def destroy
def show
@weapon = Weapon.find(params[:id])
@weapon.destroy!
redirect_to weapon_path
render "weapons/show.html.erb"
end
def weapon_params
......
......@@ -9,5 +9,9 @@
<h3 id="h3-body">by using this application, you received the privilege of seeing a customized list <br> of weapons in the MU Online Universe. In fact, the GMs (Game Masters) have been <br> generous lately and even allowed you to produce your own weapons just by filling <br> in the boxes in the next page and clicking save.</h3>
<h2 id="h2-body">Hope you enjoy!</h2>
<h4 id="a"><a href="/weapons">View Weapons</a> <a href="/admin/weapons">View Weapons as Admin</a></h4>
<h4 id="a">
<%= link_to "View Weapons", weapons_path %>
<%= link_to "View Weapons as Admin", admin_weapons_path %>
</h4>
</body>
\ No newline at end of file
<%= simple_form_for(@weapon) do |f| %>
<%= f.input :name %>
<%= f.input :weapon_type, as: :select, collection: ["Sword", "Ranged", "Spear"] %>
<%= f.input :strength %>
<%= f.input :durability %>
<%= f.submit %>
<% end %>
\ No newline at end of file
<link rel="stylesheet" type="text/css" href="/app/assets/stylesheets/application.css">
<body id="body-bg">
<%= simple_form_for(@weapon) do |f| %>
<h2>
<%= f.input :name %>
<%= f.input :weapon_type, as: :select, collection: ["Sword", "Ranged", "Spear"] %>
<%= f.input :strength %>
<%= f.input :durability %>
<%= f.submit %>
</h2>
<% end %>
</body>
\ No newline at end of file
<link rel="stylesheet" type="text/css" href="/app/assets/stylesheets/application.css">
<%= link_to("New Weapon", new_weapon_path) %>
<body id="body-bg">
<h1 align="center"> Weapons Database</h1>
<hr>
<table width = "100%">
<thead>
......@@ -26,5 +27,8 @@
</table>
<hr>
<h3 id="h3-home"><a href="/">Back to Home</a></h3>
<h3 id="h3-home">
<%= link_to("New Weapon", new_weapon_path) %>
<%= link_to("Back to Home", root_path) %>
</h3>
</body>
\ No newline at end of file
<h1><%= @weapon.name %></h1>
<h3><%= @weapon.weapon_type %></h3>
<p>
<%= @weapon.strength %>
<%= @weapon.durability %>
</p>
<link rel="stylesheet" type="text/css" href="/app/assets/stylesheets/application.css">
<hr>
<%= link_to "Back to Weapons", weapons_path %>
<body id="body-bg">
<h1><%= @weapon.name %></h1>
<h3>Type: <%= @weapon.weapon_type %></h3>
<p>
Weapon ID: <%= @weapon.id %>
<br>
Strength: <%= @weapon.strength %>
<br>
Durability: <%= @weapon.durability %>
</p>
<hr>
<%= link_to "Back to Weapons", weapons_path %>
</body>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment