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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb95969d3e15f4fb26de26dace8633b060866fc03b3df37dab175a70a05478ee
4
- data.tar.gz: 0f4f489ec92dc0b6535fa47ac97db4460aa663d3a0daee56776ec3af49f78dd7
3
+ metadata.gz: dd75ecaae7417a9fb9f9ec93574f4a6c140fa95c18b67c787de4cd2655b45fb4
4
+ data.tar.gz: 91b1351f629893606ea5b1e58d02f5bdaf9901730f7bc1c3f12e29a35fae99ff
5
5
  SHA512:
6
- metadata.gz: f2dc7bc27ffb17acd7a32abb0aad2c9f24785a4092f8bb20b46aa4cf1bf95c6b15a7f49a04e9eba0bcbc0176428ca7423ca2b63eedf89ecb87ffd01cd14f8e57
7
- data.tar.gz: 41910fff2e590bae123c5f0f6efbd1576f17945376ea20f5d4a38e41b98d3c0588565eb90b6cecbd9cdd78cfa63193ba4130a5a8d784b59b2623b606c8bdc67c
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('ajax_errors/error', model: @model)) %>";
2
+ element.innerHTML = "<%= j(render("ajax_errors/#{@template}", model: @model)) %>";
3
3
  <% if @move %>
4
4
  element.scrollIntoView(true);
5
5
  <% end %>
@@ -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
@@ -1,3 +1,3 @@
1
1
  module AjaxErrorRenderer
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  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.2.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-05-06 00:00:00.000000000 Z
11
+ date: 2019-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails