ajax_error_renderer 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/app/views/ajax_errors/error.js.erb +1 -1
- data/lib/ajax_error_renderer.rb +2 -1
- data/lib/ajax_error_renderer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd75ecaae7417a9fb9f9ec93574f4a6c140fa95c18b67c787de4cd2655b45fb4
|
4
|
+
data.tar.gz: 91b1351f629893606ea5b1e58d02f5bdaf9901730f7bc1c3f12e29a35fae99ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bd607e9454397d41317b7b3677c57b6ecc883c960f061eba46e98adf2c1b27fbb008d1c35d1af431fcfa4a822af1c07c5fd13061791c5624a47e3cac428c650
|
7
|
+
data.tar.gz: cc483f6eec2112f1df70f70937064187055a5bf8f854b63e1735095adba0a69f2774e021b5b81697189f530903ae04a144cb0b34d6ea21909debcfcdd4fcdfc0
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# AjaxErrorRenderer
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/ajax_error_renderer.svg)](https://badge.fury.io/rb/ajax_error_renderer)
|
4
|
-
|
5
|
-
[![CircleCI](https://circleci.com/gh/willnet/ajax_error_renderer/tree/master.svg?style=svg)](https://circleci.com/gh/willnet/ajax_error_renderer/tree/master)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/ajax_error_renderer.svg)](https://badge.fury.io/rb/ajax_error_renderer) [![CircleCI](https://circleci.com/gh/willnet/ajax_error_renderer/tree/master.svg?style=svg)](https://circleci.com/gh/willnet/ajax_error_renderer/tree/master)
|
6
4
|
|
7
5
|
AjaxErrorRenderer is a validation error renderer for ajax request.
|
8
6
|
|
@@ -97,6 +95,14 @@ You can create custome template with a generator like following.
|
|
97
95
|
|
98
96
|
This generator command generates `app/views/ajax_errors/_error.html.erb`, and you can customize it freely.
|
99
97
|
|
98
|
+
To use another templates, you can use `template` argument.
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
render_ajax_error model: @user, template: 'critical_error'
|
102
|
+
```
|
103
|
+
|
104
|
+
Template `app/views/ajax_errors/_critical_error.html.erb` will use.
|
105
|
+
|
100
106
|
## License
|
101
107
|
|
102
108
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -1,5 +1,5 @@
|
|
1
1
|
var element = document.querySelector('<%= @location %>');
|
2
|
-
element.innerHTML = "<%= j(render(
|
2
|
+
element.innerHTML = "<%= j(render("ajax_errors/#{@template}", model: @model)) %>";
|
3
3
|
<% if @move %>
|
4
4
|
element.scrollIntoView(true);
|
5
5
|
<% end %>
|
data/lib/ajax_error_renderer.rb
CHANGED
@@ -3,10 +3,11 @@ require "ajax_error_renderer/engine"
|
|
3
3
|
module AjaxErrorRenderer
|
4
4
|
private
|
5
5
|
|
6
|
-
def render_ajax_error(location: '#error', model:, status: 422, move: true)
|
6
|
+
def render_ajax_error(location: '#error', model:, status: 422, move: true, template: 'error')
|
7
7
|
@location = location
|
8
8
|
@model = model
|
9
9
|
@move = move
|
10
|
+
@template = template
|
10
11
|
render 'ajax_errors/error', formats: :js, status: status
|
11
12
|
end
|
12
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ajax_error_renderer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willnet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|