Mam dość długi formularz w mojej aplikacji, więc skonfigurowałem _new_form.html.erb
, który jest renderowany w moim new.html.erb
. Gdy użytkownik zaktualizuje ten formularz i przejdzie kilka podstawowych weryfikacji, chciałbym, aby zostały przekierowane na numer edit.html.erb
, który renderuje pełny formularz, tj. _new_form.html.erb
.redirect_to edit
Jestem pewien, że to podstawowe rzeczy, ale nie mogę się dowiedzieć, jak to zrobić.
Próbowałem aktualizacji akcji Utwórz w moim Contoller z poniżej, ale mam teraz gdzie.
tj
def create
@location = Location.new(params[:location])
#redirect_to :action => "edit"
respond_to do |format|
if @location.save
format.html { redirect_to edit_location_path(:id), notice: 'Location was successfully created.' }
format.json { render json: @location, status: :created, location: @location }
else
format.html { render action: "new" }
format.json { render json: @location.errors, status: :unprocessable_entity }
end
end
end
Wspaniały, dzięki mil. – Holly