Use new "strong parameters" from rails4

This commit is contained in:
Thibault Jouan
2014-04-03 02:20:37 +00:00
parent 1b5055d0a6
commit 4c6adc6927
13 changed files with 41 additions and 23 deletions

View File

@@ -8,7 +8,7 @@ class PlaylistsController < ApplicationController
end
def create
@playlist = current_user.playlists.build(params[:playlist])
@playlist = current_user.playlists.build(playlist_params)
if @playlist.save
redirect_to action: 'index'
else
@@ -22,10 +22,16 @@ class PlaylistsController < ApplicationController
def update
@playlist = Playlist.find(params[:id])
if @playlist.update_attributes params[:playlist]
if @playlist.update_attributes playlist_params
redirect_to action: 'index'
else
render action: 'edit'
end
end
private
def playlist_params
params.require(:playlist).permit(:name)
end
end