Skip to content

Support for `render` with Turbolinks in Rails controllers

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
MIT-LICENSE
Notifications You must be signed in to change notification settings

bluerail/turbolinks_render

 
 

Repository files navigation

turbolinks_render

Use render in your Rails controllers and handle the response with Turbolinks.

Turbolinks supports 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.

Installation

Add this line to your application's Gemfile:

gem 'turbolinks_render'

And then execute:

$ bundle

Usage

By default, render will be handled by Turbolinks if these conditions are met:

  • It's an ajax request
  • It's not a get request
  • It's not rendering json

You can disable turbolinks on a given request with:

render turbolinks: false

Configuration

You can invert the default behavior: never use turbolinks for rendering unless explicitly indicated. Create a file config/initializers/turbolinks_render.rb and toggle turbolinks_render.render_with_turbolinks_by_default:

Rails.application.config.turbolinks_render.render_with_turbolinks_by_default = false

In this case, to use turbolinks you should write:

render turbolinks: true

Credits

License

The gem is available as open source under the terms of the MIT License.

About

Support for `render` with Turbolinks in Rails controllers

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
MIT-LICENSE

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 75.7%
  • HTML 16.7%
  • CSS 4.4%
  • JavaScript 3.2%