diff --git a/app/controllers/weights_controller.rb b/app/controllers/weights_controller.rb index fc45ea7..065744f 100644 --- a/app/controllers/weights_controller.rb +++ b/app/controllers/weights_controller.rb @@ -10,8 +10,12 @@ class WeightsController < ApplicationController # GET /weights/1 # GET /weights/1.json def show + if params[:wrestler] + Wrestler.update(params[:wrestler].keys, params[:wrestler].values) + end @wrestlers = Wrestler.all @tournament = Tournament.find(@weight.tournament_id) + end # GET /weights/new diff --git a/app/views/weights/show.html.erb b/app/views/weights/show.html.erb index f3823a2..11a22d4 100644 --- a/app/views/weights/show.html.erb +++ b/app/views/weights/show.html.erb @@ -23,6 +23,7 @@ + <%= form_tag @wrestlers_update_path do %> <% @wrestlers.order("original_seed asc").each do |wrestler| %> <% if wrestler.weight_id == @weight.id %> @@ -30,7 +31,9 @@ <%= School.find(wrestler.school_id).name %> <% if user_signed_in? %> - <%= wrestler.original_seed %> + <%= fields_for "wrestler[]", wrestler do |w| %> + <%= w.text_field :original_seed %> + <% end %> <% else %> <%= wrestler.original_seed %> <% end %> @@ -50,6 +53,9 @@ <% end %> + <%= submit_tag "Save"%> + <% end %> + diff --git a/config/routes.rb b/config/routes.rb index dd21cb0..74d7ad3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,7 +12,7 @@ Wrestling::Application.routes.draw do resources :wrestlers - + post "/weights/:id" => "weights#show"