Quiz 2 updated

parent bfcd5dc0
...@@ -163,3 +163,6 @@ DEPENDENCIES ...@@ -163,3 +163,6 @@ DEPENDENCIES
tzinfo-data tzinfo-data
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
web-console (~> 2.0) web-console (~> 2.0)
BUNDLED WITH
1.10.4
class WeaponsController < ApplicationController class WeaponsController < ApplicationController
def index def index
@weapons = Weapon.all @weapons = Weapon.all
if params[:q].present?
@weapons = Weapon.where(name: params[:q])
end
render "weapons/index.html.erb" render "weapons/index.html.erb"
end end
...@@ -38,16 +33,15 @@ class WeaponsController < ApplicationController ...@@ -38,16 +33,15 @@ class WeaponsController < ApplicationController
end end
end end
def show def destroy
@weapon = Weapon.find(params[:id]) @weapon = Weapon.find(params[:id])
@weapon.destroy!
render "weapons/show.html.erb" redirect_to weapons_path
end end
def destroy def show
@weapon = Weapon.find(params[:id]) @weapon = Weapon.find(params[:id])
@weapon.destroy! render "weapons/show.html.erb"
redirect_to weapon_path
end end
def weapon_params def weapon_params
......
...@@ -9,5 +9,9 @@ ...@@ -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> <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> <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> </body>
\ No newline at end of file
<%= simple_form_for(@weapon) do |f| %> <link rel="stylesheet" type="text/css" href="/app/assets/stylesheets/application.css">
<%= f.input :name %>
<%= f.input :weapon_type, as: :select, collection: ["Sword", "Ranged", "Spear"] %> <body id="body-bg">
<%= f.input :strength %> <%= simple_form_for(@weapon) do |f| %>
<%= f.input :durability %> <h2>
<%= f.submit %> <%= f.input :name %>
<% end %> <%= f.input :weapon_type, as: :select, collection: ["Sword", "Ranged", "Spear"] %>
\ No newline at end of file <%= 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 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> <hr>
<table width = "100%"> <table width = "100%">
<thead> <thead>
...@@ -26,5 +27,8 @@ ...@@ -26,5 +27,8 @@
</table> </table>
<hr> <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> </body>
\ No newline at end of file
<h1><%= @weapon.name %></h1> <link rel="stylesheet" type="text/css" href="/app/assets/stylesheets/application.css">
<h3><%= @weapon.weapon_type %></h3>
<p>
<%= @weapon.strength %>
<%= @weapon.durability %>
</p>
<hr> <body id="body-bg">
<%= link_to "Back to Weapons", weapons_path %> <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