Implement playlist edit feature

* Display playlists as links in index
* Move playlist form in a partial
This commit is contained in:
Thibault Jouan
2011-07-12 11:34:40 +00:00
parent 33f979b573
commit 301205d3f0
10 changed files with 98 additions and 13 deletions

View File

@@ -15,4 +15,14 @@ class PlaylistsController < ApplicationController
render :action => 'new'
end
end
def edit
@playlist = Playlist.find(params[:id])
end
def update
@playlist = Playlist.find(params[:id])
@playlist.update_attributes params[:playlist]
redirect_to :action => 'index'
end
end

View File

@@ -0,0 +1,4 @@
= form_for @playlist do |f|
= f.label :name
= f.text_field :name
= f.submit submit_text

View File

@@ -0,0 +1 @@
= render 'form', :submit_text => 'Save'

View File

@@ -1,4 +1,5 @@
= link_to 'Create playlist', new_playlist_path
%ul
- @playlists.each do |p|
%li= p.name
%li
= link_to p.name, edit_playlist_path(p)

View File

@@ -1,4 +1 @@
= form_for @playlist do |f|
= f.label :name
= f.text_field :name
= f.submit 'Create'
= render 'form', :submit_text => 'Create'