describe 'POST :create' docontext 'with valid data' dolet(:valid_data) { FactoryGirl.attributes_for(:student) }it 'redirect to show page' dopost :create, student: valid_dataexpect(response).to redirect_to(student_path(assigns[:student]))endendend
def create@student = current_user.students.build(student_params)respond_to do |format|if @student.saveformat.html { redirect_to @student }format.json { render :show, status: :created, location: @student }elseformat.html { render :new }format.json { render json: @student.errors, status: :unprocessable_entity }endendendprivatedef student_paramsparams.require(:student).permit(:Student_Prefix, :First_Name, :Middle_Name, :Last_Name, :Father_Prefix, :Father_Name, :Father_Middle_Name, :Father_Last_Name, :Mother_Prefix, :Mother_Name, :Mother_Middle_Name, :Mother_Last_Name, :user_id)end
I am getting Id missing nil error in my create controller spec. Yet I have passed ID stuff in it still facing same everything. Here my create spec and controller file
Create Specdescribe 'POST :create' docontext 'with valid data' dolet(:valid_data) { FactoryGirl.attributes_for(:student) }it 'redirect to show page' dopost :create, student: valid_data
expect(response).to redirect_to(student_path(assigns[:student]))
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CALDHwN5oJqMmp7d_%3DjGwt%3DNXa%2BuLqL5xfYZh0kknrD5_X94xkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.