Guest User

Untitled

a guest
Dec 2nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. class PatientsController < ApplicationController
  2. .
  3. .
  4. .
  5.  
  6. def create
  7. user = User.create(email: params[:email],password: "123123")
  8. patient_params[:users_id] = user.id #preciso fazer isso e ta indo como nil :/
  9. @patient = Patient.new(patient_params)
  10. respond_to do |format|
  11. if @patient.save
  12. format.html {redirect_to @patient, notice: 'Entrada criada'}
  13. format.json { render :show, status: :created, location: @patient }
  14. else
  15. puts @patient.errors.messages
  16. format.html {render :new}
  17. format.json { render :json=> @patient.errors, status: unprocessable_entity}
  18. end
  19. end
  20. end
  21.  
  22. private
  23. def patient_params
  24. params.require(:patient).permit(:nome,:rg,:cpf,:data_nascimento,
  25. :cep,:rua,:numero,:complemento,:bairro,:cidade,:uf,:plano_saudes_id,
  26. :telefone1,:telefone2,:users_id,:avatar)
  27. end
Add Comment
Please, Sign In to add comment