Begin adding edit functionality
This commit is contained in:
parent
89cfba504c
commit
71b047be48
5 changed files with 24 additions and 1 deletions
|
@ -6,4 +6,8 @@ class WorkoutsController < ApplicationController
|
|||
def show
|
||||
@workout = Workout.find(params[:id])
|
||||
end
|
||||
|
||||
def edit
|
||||
@workout = Workout.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
|
5
app/views/workouts/_form.html.erb
Normal file
5
app/views/workouts/_form.html.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
<%= form_for @workout do |f| %>
|
||||
<%= f.label :date %>
|
||||
<%= f.text_field :date %>
|
||||
<%= f.submit nil %>
|
||||
<% end %>
|
1
app/views/workouts/edit.html.erb
Normal file
1
app/views/workouts/edit.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= render :partial => 'form' %>
|
|
@ -1,5 +1,9 @@
|
|||
<ul>
|
||||
<% @workouts.each do |workout| %>
|
||||
<li><%= link_to workout.date, workout %></li>
|
||||
<li id="workout_<%= workout.id %>">
|
||||
<%= link_to workout.date, workout %> [
|
||||
<%= link_to 'Edit', edit_workout_path(workout) %> |
|
||||
]
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
|
@ -36,4 +36,13 @@ describe "Workouts" do
|
|||
page.should have_content @workout.date
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT /workouts/(:id)" do
|
||||
it "should edit the workout" do
|
||||
visit workouts_path
|
||||
find("#workout_#{@workout.id}").click_link 'Edit'
|
||||
|
||||
current_path.should == edit_workout_path(@workout)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue