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:
@@ -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
|
||||
|
Reference in New Issue
Block a user