Advertisement
YarikHrom

Untitled

Mar 24th, 2022
1,116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.81 KB | None | 0 0
  1. # frozen_string_literal: true
  2.  
  3. module API
  4.   module V1
  5.     class UsersController < API::V1::BaseController
  6.       skip_verify_authorized only: %i[show update suggestions]
  7.  
  8.       def show
  9.         render json: @current_user
  10.       end
  11.  
  12.       def update
  13.         @current_user.update(user_params)
  14.         byebug
  15.         render json: @current_user
  16.       end
  17.  
  18.       # app/graphql/queries/suggestions.rb
  19.       def suggestions
  20.         autocomplete = params[:autocomplete]
  21.         @suggestions = Boards::Suggestions.new(autocomplete).call
  22.  
  23.         render json: {
  24.           data: {
  25.             suggestions: @suggestions
  26.           }
  27.         }
  28.       end
  29.  
  30.       private
  31.  
  32.       def user_params
  33.         params.require(:data_form).permit(:nickname, :first_name, :last_name, :avatar)
  34.       end
  35.     end
  36.   end
  37. end
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement