Use new "strong parameters" from rails4
This commit is contained in:
@@ -7,8 +7,14 @@ module API
|
||||
end
|
||||
|
||||
def create
|
||||
@playlist = current_user.playlists.build(params[:playlist].slice(:name))
|
||||
@playlist = current_user.playlists.build(playlist_params)
|
||||
@playlist.save
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def playlist_params
|
||||
params.require(:playlist).permit(:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -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
|
||||
|
@@ -8,11 +8,17 @@ class TracksController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@track = Track.new params[:track]
|
||||
@track = Track.new track_params
|
||||
if @track.save
|
||||
redirect_to @track
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def track_params
|
||||
params.require(:track).permit(:name, :file)
|
||||
end
|
||||
end
|
||||
|
@@ -6,7 +6,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@user = User.new(params[:user])
|
||||
@user = User.new(user_params)
|
||||
if !@user.save
|
||||
render :new
|
||||
else
|
||||
@@ -14,4 +14,10 @@ class UsersController < ApplicationController
|
||||
redirect_to :root
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:email, :password, :password_confirmation)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user