I have two steps.
Step 3 – Creates a new project.
Step 4 – Creates a new discussion post for that project that was just made in step 3.
Problem is; I cannot figure out how to get Step 4 to know the project_id for the project that was just made. Step 3 uses projects_controller and Step 4 uses posts_controller. I am thinking of using Sessions[] in def Create in the projects_controller and then somehow getting that value in def New in the posts_controller. Not working, or can’t figure how to unfortunately.
projects_controller
def create
@project = current_user.projects.build(params[:project])
session[:step3_project_id] = params[:id]
respond_to do |format|
if @project.save
format.html { redirect_to project_step_4_path, notice: 'Project was successfully created.' }
format.json { render json: @project, status: :created, location: @project }
else
format.html { render action: "new" }
format.json { render json: @project.errors, status: :unprocessable_entity }
end
end
end
1 Answer