render in your Rails controllers and handle the response with Turbolinks.
redirect_to out of the box. But
render is not supported and you have to use workarounds for common things like dealing with forms. This gem aims to fix that.
I think Turbolinks/Rails should handle this officially. If you agree you can vote for this idea.
Add this line to your application's Gemfile:
And then execute:
render will be handled by Turbolinks if these conditions are met:
- It's an ajax request
- It's not a
- It's not rendering json
When these conditions are met and
render is used:
- An event
You can disable turbolinks on a given request with:
render turbolinks: false
You can invert the default behavior: never use turbolinks for rendering unless explicitly indicated. Create a file
config/initializers/turbolinks_render.rb and toggle
Rails.application.config.turbolinks_render.render_with_turbolinks_by_default = false
In this case, to use turbolinks you should write:
render turbolinks: true
The gem is available as open source under the terms of the MIT License.