项目作者: ElMassimo

项目描述 :
↩️ Provides redirect support for ajax requests in Rails
高级语言: Ruby
项目地址: git://github.com/ElMassimo/rails-ajax_redirect.git
创建时间: 2015-12-29T21:09:21Z
项目社区:https://github.com/ElMassimo/rails-ajax_redirect

开源协议:MIT License

下载


Rails::AjaxRedirect

Gem Version
License

Simple redirect_to support for AJAX requests in non-Turbolinks applications.

Installation

Add this line to your application’s Gemfile:

  1. gem 'rails-ajax_redirect'

Or install it yourself as:

  1. gem install rails-ajax_redirect

Usage

Require rails-ajax_redirect in your application.js:

  1. //= require rails-ajax_redirect

AjaxRedirect extends redirect_to to use a custom status code for ajax
requests, while still setting the Location header.

The script adds a handler for the ajax:success event, that navigates to the
location in the header for responses that have the custom status code.

Now you will be able to write controller actions in the usual way :smiley:

If your application uses Turbolinks check out turbolinks-redirect, on which this library is based on. The advantage is that
it will perform faster navigation by leveraging Turbolinks to visit the new
location.

License

  1. Copyright (c) 2015 Máximo Mussini
  2. Permission is hereby granted, free of charge, to any person obtaining
  3. a copy of this software and associated documentation files (the
  4. "Software"), to deal in the Software without restriction, including
  5. without limitation the rights to use, copy, modify, merge, publish,
  6. distribute, sublicense, and/or sell copies of the Software, and to
  7. permit persons to whom the Software is furnished to do so, subject to
  8. the following conditions:
  9. The above copyright notice and this permission notice shall be
  10. included in all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  12. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  14. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  15. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  16. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  17. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.