Skip to content

Commit

Permalink
change username param to _username
Browse files Browse the repository at this point in the history
  • Loading branch information
riskimidiw committed Dec 27, 2018
1 parent 4fb0945 commit c140c00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/controllers/users_controller.rb
Expand Up @@ -28,7 +28,7 @@ def create
def update
if @user.nil?
render json: { errors: 'User not found' }, status: :not_found
elsif @user.update(user_params)
elsif !@user.update(user_params)
render json: { errors: @user.errors.full_messages },
status: :unprocessable_entity
end
Expand All @@ -45,7 +45,7 @@ def destroy
private

def find_user
@user = User.find_by_username(params[:username])
@user = User.find_by_username(params[:_username])
end

def user_params
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
@@ -1,6 +1,6 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :users, param: :username
resources :users, param: :_username
post '/auth/login', to: 'authentication#login'
get '/*a', to: 'application#not_found'
end

0 comments on commit c140c00

Please sign in to comment.