Implement playlist edit feature
* Display playlists as links in index * Move playlist form in a partial
This commit is contained in:
@@ -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
|
||||
|
4
app/views/playlists/_form.html.haml
Normal file
4
app/views/playlists/_form.html.haml
Normal file
@@ -0,0 +1,4 @@
|
||||
= form_for @playlist do |f|
|
||||
= f.label :name
|
||||
= f.text_field :name
|
||||
= f.submit submit_text
|
1
app/views/playlists/edit.html.haml
Normal file
1
app/views/playlists/edit.html.haml
Normal file
@@ -0,0 +1 @@
|
||||
= render 'form', :submit_text => 'Save'
|
@@ -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)
|
||||
|
@@ -1,4 +1 @@
|
||||
= form_for @playlist do |f|
|
||||
= f.label :name
|
||||
= f.text_field :name
|
||||
= f.submit 'Create'
|
||||
= render 'form', :submit_text => 'Create'
|
||||
|
Reference in New Issue
Block a user