Fix coding standards in application files
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
module API
|
||||
class ApplicationController < ::ApplicationController
|
||||
skip_before_filter :verify_authenticity_token
|
||||
skip_before_filter :authenticate!, only: [:cor_preflight]
|
||||
skip_before_filter :authenticate!, only: :cor_preflight
|
||||
|
||||
before_filter :cor_filter
|
||||
|
||||
|
@@ -5,14 +5,15 @@ module API
|
||||
end
|
||||
|
||||
def create
|
||||
@playlist = current_user.playlists.build(playlist_params)
|
||||
@playlist = current_user.playlists.build playlist_params
|
||||
@playlist.save
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def playlist_params
|
||||
params.require(:playlist).permit(:name)
|
||||
params.require(:playlist).permit :name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -1,11 +1,11 @@
|
||||
module API
|
||||
class SessionsController < ApplicationController
|
||||
skip_before_filter :authenticate!, only: [:create]
|
||||
skip_before_filter :authenticate!, only: :create
|
||||
|
||||
def create
|
||||
user = User.find_by_email(params[:session][:email])
|
||||
|
||||
unless user.try(:authenticate?, params[:session][:password])
|
||||
unless user.try :authenticate?, params[:session][:password]
|
||||
return render json: '', status: :not_found
|
||||
end
|
||||
|
||||
|
@@ -2,7 +2,7 @@ module API
|
||||
class SoundsController < ApplicationController
|
||||
# FIXME: add some tests!
|
||||
def show
|
||||
sound = Sound.find params[:id]
|
||||
sound = Sound.find(params[:id])
|
||||
send_file sound.path, type: sound.mime_type
|
||||
end
|
||||
end
|
||||
|
@@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
before_filter :authenticate!
|
||||
|
||||
def current_user=(user)
|
||||
def current_user= user
|
||||
session[:user_id] = user.id
|
||||
end
|
||||
|
||||
@@ -11,6 +11,7 @@ class ApplicationController < ActionController::Base
|
||||
@current_user ||= User.find(session[:user_id]) if session[:user_id]
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
|
||||
def authenticate!
|
||||
|
@@ -1,6 +1,6 @@
|
||||
class HomeController < ApplicationController
|
||||
def index
|
||||
@playlists = Playlist.all
|
||||
@tracks = Track.latest
|
||||
@playlists = Playlist.all
|
||||
@tracks = Track.latest
|
||||
end
|
||||
end
|
||||
|
@@ -8,7 +8,8 @@ class PlaylistsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@playlist = current_user.playlists.build(playlist_params)
|
||||
@playlist = current_user.playlists.build playlist_params
|
||||
|
||||
if @playlist.save
|
||||
redirect_to action: 'index'
|
||||
else
|
||||
@@ -22,6 +23,7 @@ class PlaylistsController < ApplicationController
|
||||
|
||||
def update
|
||||
@playlist = Playlist.find(params[:id])
|
||||
|
||||
if @playlist.update_attributes playlist_params
|
||||
redirect_to action: 'index'
|
||||
else
|
||||
@@ -29,9 +31,10 @@ class PlaylistsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def playlist_params
|
||||
params.require(:playlist).permit(:name)
|
||||
params.require(:playlist).permit :name
|
||||
end
|
||||
end
|
||||
|
@@ -1,9 +1,10 @@
|
||||
class SessionsController < ApplicationController
|
||||
skip_before_filter :authenticate!, only: [:new, :create]
|
||||
skip_before_filter :authenticate!, only: %i[new create]
|
||||
|
||||
def create
|
||||
user = User.find_by_email(params[:session][:email])
|
||||
if user.try(:authenticate?, params[:session][:password])
|
||||
|
||||
if user.try :authenticate?, params[:session][:password]
|
||||
self.current_user = user
|
||||
redirect_to :root
|
||||
else
|
||||
|
@@ -1,6 +1,6 @@
|
||||
class SoundsController < ApplicationController
|
||||
def show
|
||||
sound = Sound.find params[:id]
|
||||
sound = Sound.find(params[:id])
|
||||
send_file sound.path, type: sound.mime_type
|
||||
end
|
||||
end
|
||||
|
@@ -1,6 +1,6 @@
|
||||
class TracksController < ApplicationController
|
||||
def show
|
||||
@track = Track.find params[:id]
|
||||
@track = Track.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -8,7 +8,8 @@ class TracksController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@track = Track.new track_params
|
||||
@track = Track.new(track_params)
|
||||
|
||||
if @track.save
|
||||
redirect_to @track
|
||||
else
|
||||
@@ -19,6 +20,6 @@ class TracksController < ApplicationController
|
||||
private
|
||||
|
||||
def track_params
|
||||
params.require(:track).permit(:name, :file)
|
||||
params.require(:track).permit %i[name file]
|
||||
end
|
||||
end
|
||||
|
@@ -1,5 +1,5 @@
|
||||
class UsersController < ApplicationController
|
||||
skip_before_filter :authenticate!, only: [:new, :create]
|
||||
skip_before_filter :authenticate!, only: %i[new create]
|
||||
|
||||
def new
|
||||
@user = User.new
|
||||
@@ -7,6 +7,7 @@ class UsersController < ApplicationController
|
||||
|
||||
def create
|
||||
@user = User.new(user_params)
|
||||
|
||||
if !@user.save
|
||||
render :new
|
||||
else
|
||||
@@ -18,6 +19,6 @@ class UsersController < ApplicationController
|
||||
private
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:email, :password, :password_confirmation)
|
||||
params.require(:user).permit %i[email password password_confirmation]
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user