What we want to do
To send to the confirm action (confirm action), we need to give an option to change the destination.
So, you can simply edit form_for and give the option url: confirm_blogs_pathurl
to make it look like this
<%= form_for(@blog, url: confirm_blogs_path) do |f| %>
This would result in an error when executing the edit action. To avoid this error, create a helper method so that the url: confirm_blogs_path
option is generated for the new action and the blogs_path
option is generated for the update action.
module BlogsHelper
def choose_new_or_edit
if action_name == 'new' || action_name == 'confirm'
confirm_blogs_path
elsif action_name == 'edit'
blog_path
end
end
end
app/views/blogs/_form.html.erb
<%= form_for(@blog, url: choose_new_or_edit) do |f| %>
Above.