I have some url
get '/vacancies/:id(/:mode)', to: 'vacancies#show', as: 'vacancy', constraints: { mode: /(resume|file)/}
inside show view user can fill in the form and send request to the server. If User sent not valid params I should redirect him back, show validation error and also I should keep filled in params.
How can I implement this stuff?
upd1
Typical rails solution for this is something like render :new or render :edit, but in my case I can't do render :show because is rendering view for '/vacancies/:id route not for '/vacancies/:id(/:mode).
Also I tried do redirect_to :back and this works fine except one thing: params are not passed through request.
I guess there is solution inside response object, but didn't find yet
upd2
class VacanciesController < ApplicationController
# vacancies/:id - is just show view
# vacancies/:id/resume - is show view with form
# vacancirs/:id/file - is show view with form for sending pdf|doc|etc
def show
@vacancy = Vacancy.find(params[:id])
end
def create
if Vacancy::SaveResume.new(resume_params).call.valid?
redirect_to vacancies_path
else
# didn't know what to do there
end
end
end