Add basic playlists management

* Index of playlists
* Create a new playlist
* Basic playlist model with mandatory name
This commit is contained in:
Thibault Jouan
2011-07-09 09:23:32 +00:00
parent 74fb4ca86f
commit 33f979b573
13 changed files with 205 additions and 57 deletions

View File

@@ -0,0 +1,18 @@
class PlaylistsController < ApplicationController
def index
@playlists = Playlist.all
end
def new
@playlist = Playlist.new
end
def create
@playlist = Playlist.new params[:playlist]
if @playlist.save
redirect_to :action => 'index'
else
render :action => 'new'
end
end
end

3
app/models/playlist.rb Normal file
View File

@@ -0,0 +1,3 @@
class Playlist < ActiveRecord::Base
validates_presence_of :name
end

View File

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

View File

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