Created
August 30, 2020 15:00
-
-
Save elliott-king/f88d207f351017b75ad924b1251d71d2 to your computer and use it in GitHub Desktop.
Controller to create new user and attach Active Storage file ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
def create | |
resume = params[:pdf] | |
params = user_params.except(:pdf) | |
user = User.create!(params) | |
user.resume.attach(resume) if resume.present? && !!user | |
render json: user.as_json(root: false, methods: :resume_url).except('updated_at') | |
end | |
private | |
def user_params | |
params.permit(:email, :first_name, :last_name, :pdf) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment