Improve tracks CRUD

* Add index, edit and update action;
* Add _form partial;
* Add link to tracks/index in nav;
* Refactor specs.
This commit is contained in:
Thibault Jouan
2015-05-01 12:09:29 +00:00
parent e1c8a6038d
commit 5e1757aff9
9 changed files with 70 additions and 25 deletions

View File

@@ -1,4 +1,8 @@
class TracksController < ApplicationController
def index
@tracks = Track.all
end
def show
@track = Track.find(params[:id])
end
@@ -7,6 +11,10 @@ class TracksController < ApplicationController
@track = Track.new
end
def edit
@track = Track.find(params[:id])
end
def create
@track = Track.new(track_params)
@@ -17,6 +25,17 @@ class TracksController < ApplicationController
end
end
def update
@track = Track.find(params[:id])
if @track.update_attributes track_params
redirect_to action: :index
else
render :edit
end
end
private
def track_params