I have a Pages model with field 'customURL'. I can do page#show at '/:customurl'. but because i've defined page show that way in routes, my create action now does a redirect on success to the wrong route. What should I change to most cleanly fix the redirect properly to point to '/:customurl' on save?
controller:
def create
@page = Page.new(params[:page])
respond_to do |format|
if @page.save
format.html { redirect_to page_url, notice: 'Page was successfully created.' }
format.json { render json: @page, status: :created, location: @page }
else
format.html { render action: "new" }
format.json { render json: @page.errors, status: :unprocessable_entity }
end
end
end
routes:
resources :pages
...
get "/:customURL" => "pages#show"
Thanks!