All Projects → jorgemanrubia → Turbolinks_render

jorgemanrubia / Turbolinks_render

Licence: mit
Support for `render` with Turbolinks in Rails controllers

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Turbolinks render

Paperclip Meta
Adds width, height, and size to paperclip images.
Stars: ✭ 157 (-6.55%)
Mutual labels:  rails
Ruby Bookmarks
Ruby and Ruby on Rails bookmarks collection
Stars: ✭ 1,972 (+1073.81%)
Mutual labels:  rails
Stackneveroverflow
A simple Q&A platform using Ruby on Rails, support markdown.
Stars: ✭ 164 (-2.38%)
Mutual labels:  rails
X Editable Rails
Edit fields easily with X-Editable helper
Stars: ✭ 159 (-5.36%)
Mutual labels:  rails
Yaaf
Easing the form object pattern in Rails applications
Stars: ✭ 161 (-4.17%)
Mutual labels:  rails
Rails Base
Skeleton for new Rails based projects.
Stars: ✭ 161 (-4.17%)
Mutual labels:  rails
Responders
A set of Rails responders to dry up your application
Stars: ✭ 1,925 (+1045.83%)
Mutual labels:  rails
Capistrano Rails Console
Capistrano plugin which adds a remote rails console and dbconsole
Stars: ✭ 166 (-1.19%)
Mutual labels:  rails
Rubanok
Parameters-based transformation DSL
Stars: ✭ 161 (-4.17%)
Mutual labels:  rails
Her
Her is an ORM (Object Relational Mapper) that maps REST resources to Ruby objects. It is designed to build applications that are powered by a RESTful API instead of a database.
Stars: ✭ 1,974 (+1075%)
Mutual labels:  rails
Api guard
JWT authentication solution for Rails APIs
Stars: ✭ 159 (-5.36%)
Mutual labels:  rails
Expertiza
Expertiza is a web application through which students can submit and peer-review learning objects (articles, code, web sites, etc). The Expertiza project is supported by the National Science Foundation.
Stars: ✭ 160 (-4.76%)
Mutual labels:  rails
Sentimentalizer
Sentiment analysis with Machine Learning
Stars: ✭ 162 (-3.57%)
Mutual labels:  rails
Draftsman
Ruby gem that lets you create draft versions of your database records.
Stars: ✭ 159 (-5.36%)
Mutual labels:  rails
Staytus
💡 An open source solution for publishing the status of your services
Stars: ✭ 2,032 (+1109.52%)
Mutual labels:  rails
Hound
Automated code review for GitHub pull requests.
Stars: ✭ 1,904 (+1033.33%)
Mutual labels:  rails
Authie
👮‍♂️ Improve user session security in Ruby on Rails applications with database session storage
Stars: ✭ 161 (-4.17%)
Mutual labels:  rails
Awesome Opensource Apps
🏠ℹ️ Curated list of awesome open source crafted web & mobile applications - Learn, Fork, Contribute & Most Importantly Enjoy!
Stars: ✭ 2,199 (+1208.93%)
Mutual labels:  rails
Flipflop
Flipflop lets you declare and manage feature flags in your Rails application.
Stars: ✭ 165 (-1.79%)
Mutual labels:  rails
Wheel
Don't reinvent the wheel for every new Rails project. Use sane Defaults.
Stars: ✭ 163 (-2.98%)
Mutual labels:  rails

CircleCI

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.

I think Turbolinks/Rails should handle this officially. If you agree you can vote for this idea.

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 generates an html response (text/html content type)

When these conditions are met and render is used:

  • The page content is replaced with the rendered content with Javascript. It uses Turbolinks to do this replacement, so it is pretty smart about keeping the <head> when it's identical, executing <script> elements, etc.
  • An event turbolinks:load is dispatched

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

You can also ignore specific paths in your application. This can be useful if you're using an engine and don't have access to its code to change the render calls. For instance, to ignore anything that starts with /admin:

Rails.application.config.turbolinks_render.ignored_paths = [
  '/admin'
]

Implementation notes

  • It configures a rack middleware that intercept requests and modify responses when the expected conditions are met.
  • It uses some internal Turbolinks classes to perform the rendering. This makes the DOM-update logic very smart but it could introduce problems with future Turbolink versions , since this does not belong to its public API. I'll do my best to keep things up to date.

Example

An example and an explanatory blog post are also available.

Credits

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].