Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PatientsController < ApplicationController
- .
- .
- .
- def create
- user = User.create(email: params[:email],password: "123123")
- patient_params[:users_id] = user.id #preciso fazer isso e ta indo como nil :/
- @patient = Patient.new(patient_params)
- respond_to do |format|
- if @patient.save
- format.html {redirect_to @patient, notice: 'Entrada criada'}
- format.json { render :show, status: :created, location: @patient }
- else
- puts @patient.errors.messages
- format.html {render :new}
- format.json { render :json=> @patient.errors, status: unprocessable_entity}
- end
- end
- end
- private
- def patient_params
- params.require(:patient).permit(:nome,:rg,:cpf,:data_nascimento,
- :cep,:rua,:numero,:complemento,:bairro,:cidade,:uf,:plano_saudes_id,
- :telefone1,:telefone2,:users_id,:avatar)
- end
Add Comment
Please, Sign In to add comment