As you are using nested resources, update the create action as below:
def create
@list = List.find(params[:list_id])
@step = @list.steps.build(step_params) ## Assuming that list has_many steps
respond_to do |f|
if @step.save
## update the url passed to redirect_to as below
f.html { redirect_to list_step_url(@list,@step), notice: 'Step was successfully created.' }
f.json { render action: 'show', status: :created, location: @step }
else
f.html { render action: 'new' }
f.json { render json: @step.errors, status: :unprocessable_entity }
end
end
end
Run rake routes
to see the available routes.
As route to steps#show would look something like
GET lists/:list_id/steps/:id steps#show
Use list_step_url
with 2 arguments @list
For :list_id and @step
for :id to go to show page of Step.