Commit a714fcb1 authored by Bianca Tarun's avatar Bianca Tarun

edited quiz 2

parent 28c45ecd
......@@ -13,7 +13,7 @@ module Admin
def update
@sport = Sport.find(params[:id])
if @sports.update(admin_sport_params())
if @sport.update(admin_sport_params())
redirect_to admin_sport_path(@sport.id)
else
render "/admin/sports/edit.html.erb"
......@@ -47,7 +47,7 @@ module Admin
redirect_to admin_sports_path
end
def sport_params
def admin_sport_params
params.require(:sport).permit!
end
......
<%= simple_form_for(@sport) do |f| %>
<%= simple_form_for([:admin, @sport]) do |f| %>
<%= f.input :name %>
<hr>
<%= f.input :description %>
......
......@@ -25,4 +25,4 @@
<% end %>
</table>
<hr>
<a href= "/pages/index">Back to Homepage</a>
\ No newline at end of file
<a href= "/">Back to Homepage</a>
\ No newline at end of file
<h1>All User Sports</h1>
<%= link_to("New Sport", new_sport_path) %>
<hr>
<table width="100%">
<tr>
......@@ -18,8 +16,6 @@
<td><%= sport.category %></td>
<td>
<%= link_to "Show", sport_path(sport.id) %>
<%= link_to "Edit", edit_sport_path(sport.id) %>
<%= link_to "Delete", sport_path(sport.id), method: :delete, data: { confirm: 'Are you sure?' } %>
</td>
</tr>
<% end %>
......
Rails.application.routes.draw do
root to: "pages#index"
resources :sports#, only: [:create, :index, :show]
resources :sports, only: [:index, :show]
namespace :admin do
resources :sports
......
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