Commit a714fcb1 authored by Bianca Tarun's avatar Bianca Tarun

edited quiz 2

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