So I have a controller action looking like this:
def create
@term = Term.new(term_params)
if @term.save
redirect_to(@term)
else
render :new
end
end
When validation fails the new actions view is rendered and user can see the errors that were made. The problem is that this also changes the URL to localhost:3000/terms
so when the user would for some reason want to refresh the page, then rails would want to redirect that user to terms index
page. Is there a simple way to keep the user on the new term
page after refresh?
I actually don't have a index
page for terms
as I dont't need it, so this whole situation will throw an error in this case.
Please,take this in consideration:
Your are seeing terms
but is not the same like the "index of terms". Thing is, using https, in the path of your "new" action. Index use "get" and create use "post". So, looks the same but is not.
I think in your routes files, you need to define the "post" path in a explict way.
post "new-term" => terms#new
and maybe define in your controller to:
render new_term_path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With