Reputation: 19031
I think something is wrong with my create method.
When I create a new resume from http://localhost:3000/ or http://localhost:3000/resumes/new, I get the routing error shown below.
Routing Error
No route matches {:action=>"show", :controller=>"resumes"}
The app goes to http://localhost:3000/resumes address instead of http://localhost:3000/resumes/1. Not sure why.
class SubmissionsController < ApplicationController
def create
@resume = Resume.new(params[:resume])
if @resume.save
#UserMailer.created_resume_email(@user).deliver
redirect_to :action => 'show'
format.html { redirect_to(@resume, :notice => 'Resume was successfully created.') }
format.xml { render :xml => @resume, :status => :created, :location => @resume }
else
@title = "Create a new resume"
render 'new'
end
end
def show
@resume = Resume.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @resume }
end
end
end
Leaflet::Application.routes.draw do
resources :resumes
match '/' => 'resumes#new'
end
Upvotes: 0
Views: 371
Reputation: 5598
I may be missing something, but, I believe you need to alter your redirect_to statement.
redirect_to resume_url(@resume)
or
redirect_to resume_path(@resume)
That should redirect the user to the "show" action in your controller with the required parameter for determining which resume to get and show.
http://guides.rubyonrails.org/layouts_and_rendering.html#using-redirect_to
Upvotes: 1