responders 2.0.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -1
- data/MIT-LICENSE +1 -1
- data/README.md +108 -41
- data/lib/action_controller/respond_with.rb +28 -9
- data/lib/action_controller/responder.rb +9 -3
- data/lib/generators/rails/responders_controller_generator.rb +1 -25
- data/lib/generators/rails/templates/api_controller.rb +51 -0
- data/lib/generators/rails/templates/controller.rb +6 -4
- data/lib/generators/responders/install_generator.rb +8 -0
- data/lib/responders.rb +0 -6
- data/lib/responders/controller_method.rb +3 -1
- data/lib/responders/location_responder.rb +1 -1
- data/lib/responders/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ba43cee72d6a197eff78818683a01dfe43814d3
|
4
|
+
data.tar.gz: 37ceb10a23ee46f1ec142176eee690c33a98b73d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e198e8715fefd1e87c21d7a52ed255ad51445bdfe2eb83e0e8a5eb8845eae8d3b1e665217ce1ac6f836156abd1d56cff5a2082f48cfb6f44e3cabe875117125f
|
7
|
+
data.tar.gz: c59cbdaf34207e264e7551bdd700f2d9afe200fa29c2a31672d79debce0979853c76ee8ce0500347f5ee8fb19ebf8b86fc270a45add262d06b4d9c43c7c7ae17
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## 2.2.0
|
2
|
+
|
3
|
+
* Added the `verify_request_format!` method, that can be used as a `before_action`
|
4
|
+
callback to prevent your actions from being invoked when the controller does
|
5
|
+
not respond to the request mime type, preventing the execution of complex
|
6
|
+
queries or creating/deleting records from your app.
|
7
|
+
|
8
|
+
## 2.1.2
|
9
|
+
|
10
|
+
* Fix rendering when using `ActionController::API`. (by @eLod)
|
11
|
+
* Added API controller template for the controller generator. (by @vestimir)
|
12
|
+
|
13
|
+
## 2.1.1
|
14
|
+
|
15
|
+
* Added support for Rails 5.
|
16
|
+
|
17
|
+
## 2.1.0
|
18
|
+
|
19
|
+
* No longer automatically set the responders generator as many projects may use this gem as a dependency. When upgrading, users will need to add `config.app_generators.scaffold_controller :responders_controller` to their application. The `responders:install` generator has been updated to automatically insert it in new applications
|
20
|
+
|
1
21
|
## 2.0.1
|
2
22
|
|
3
23
|
* Require `rails/railtie` explicitly before using it
|
@@ -8,7 +28,7 @@
|
|
8
28
|
|
9
29
|
* Import `respond_with` and class-level `respond_to` from Rails
|
10
30
|
* Support only Rails ~> 4.2
|
11
|
-
* `Responders::LocationResponder` is now included by
|
31
|
+
* `Responders::LocationResponder` is now included by the default responder (and therefore deprecated)
|
12
32
|
|
13
33
|
## 1.1.0
|
14
34
|
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright 2009-
|
1
|
+
Copyright 2009-2016 Plataformatec. http://plataformatec.com.br
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -1,10 +1,25 @@
|
|
1
1
|
# Responders
|
2
2
|
|
3
|
-
[![Gem Version](https://fury-badge.herokuapp.com/rb/responders.
|
4
|
-
[![Build Status](https://api.travis-ci.org/plataformatec/responders.
|
5
|
-
[![Code Climate](https://codeclimate.com/github/plataformatec/responders.
|
3
|
+
[![Gem Version](https://fury-badge.herokuapp.com/rb/responders.svg)](http://badge.fury.io/rb/responders)
|
4
|
+
[![Build Status](https://api.travis-ci.org/plataformatec/responders.svg?branch=master)](http://travis-ci.org/plataformatec/responders)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/plataformatec/responders.svg)](https://codeclimate.com/github/plataformatec/responders)
|
6
6
|
|
7
|
-
A set of responders modules to dry up your Rails
|
7
|
+
A set of responders modules to dry up your Rails 4.2+ app.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add the responders gem to your Gemfile:
|
12
|
+
|
13
|
+
gem "responders"
|
14
|
+
|
15
|
+
Update your bundle and run the install generator:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
$ rails g responders:install
|
19
|
+
|
20
|
+
If you are including this gem to support backwards compatibilty for responders in previous releases of Rails, you only need to include the gem and bundle.
|
21
|
+
|
22
|
+
$ bundle install
|
8
23
|
|
9
24
|
## Responders Types
|
10
25
|
|
@@ -60,15 +75,27 @@ You can also have embedded HTML. Just create a `_html` scope.
|
|
60
75
|
|
61
76
|
See also the `namespace_lookup` option to search the full hierarchy of possible keys.
|
62
77
|
|
78
|
+
### HttpCacheResponder
|
79
|
+
|
80
|
+
Automatically adds Last-Modified headers to API requests. This
|
81
|
+
allows clients to easily query the server if a resource changed and if the client tries
|
82
|
+
to retrieve a resource that has not been modified, it returns not_modified status.
|
83
|
+
|
84
|
+
### CollectionResponder
|
85
|
+
|
86
|
+
Makes your create and update action redirect to the collection on success.
|
87
|
+
|
63
88
|
### LocationResponder
|
64
89
|
|
65
90
|
This responder allows you to use callable objects as the redirect location.
|
66
91
|
Useful when you want to use the `respond_with` method with
|
67
92
|
a custom route that requires persisted objects, but the validation may fail.
|
68
93
|
|
94
|
+
Note: this responder is included by default, and doesn't need to be included
|
95
|
+
on the top of your controller (including it will issue a deprecation warning).
|
96
|
+
|
69
97
|
```ruby
|
70
98
|
class ThingsController < ApplicationController
|
71
|
-
responders :location, :flash
|
72
99
|
respond_to :html
|
73
100
|
|
74
101
|
def create
|
@@ -78,59 +105,48 @@ class ThingsController < ApplicationController
|
|
78
105
|
end
|
79
106
|
```
|
80
107
|
|
81
|
-
|
82
|
-
|
83
|
-
Automatically adds Last-Modified headers to API requests. This
|
84
|
-
allows clients to easily query the server if a resource changed and if the client tries
|
85
|
-
to retrieve a resource that has not been modified, it returns not_modified status.
|
108
|
+
**Dealing with namespaced routes**
|
86
109
|
|
87
|
-
|
110
|
+
In order for the LocationResponder to find the correct route helper for namespaced routes you need to pass the namespaces to `respond_with`:
|
88
111
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
The first step is to install the responders gem and configure it in your application:
|
112
|
+
```ruby
|
113
|
+
class Api::V1::ThingsController < ApplicationController
|
114
|
+
respond_to :json
|
94
115
|
|
95
|
-
|
96
|
-
|
116
|
+
# POST /api/v1/things
|
117
|
+
def create
|
118
|
+
@thing = Thing.create(thing_params)
|
119
|
+
respond_with :api, :v1, @thing
|
120
|
+
end
|
121
|
+
end
|
97
122
|
```
|
98
123
|
|
99
|
-
|
100
|
-
|
101
|
-
```ruby
|
102
|
-
gem 'responders'
|
103
|
-
```
|
124
|
+
## Configuring your own responder
|
104
125
|
|
105
|
-
Responders only provides a set of modules
|
106
|
-
responder.
|
126
|
+
Responders only provides a set of modules and to use them you have to create your own
|
127
|
+
responder. After you run the install command, the following responder will be
|
128
|
+
generated in your application:
|
107
129
|
|
108
130
|
```ruby
|
109
|
-
# lib/
|
110
|
-
class
|
131
|
+
# lib/application_responder.rb
|
132
|
+
class ApplicationResponder < ActionController::Responder
|
111
133
|
include Responders::FlashResponder
|
112
134
|
include Responders::HttpCacheResponder
|
113
135
|
end
|
114
136
|
```
|
115
137
|
|
116
|
-
|
138
|
+
Your application also needs to be configured to use it:
|
117
139
|
|
118
140
|
```ruby
|
119
141
|
# app/controllers/application_controller.rb
|
120
|
-
require "
|
142
|
+
require "application_responder"
|
121
143
|
|
122
144
|
class ApplicationController < ActionController::Base
|
123
|
-
self.responder =
|
145
|
+
self.responder = ApplicationResponder
|
124
146
|
respond_to :html
|
125
147
|
end
|
126
148
|
```
|
127
149
|
|
128
|
-
Or, for your convenience, just do:
|
129
|
-
|
130
|
-
```console
|
131
|
-
rails generate responders:install
|
132
|
-
```
|
133
|
-
|
134
150
|
## Controller method
|
135
151
|
|
136
152
|
This gem also includes the controller method `responders`, which allows you to cherry-pick which
|
@@ -168,17 +184,68 @@ Now you would see the message "bob@bob.com was successfully created" instead of
|
|
168
184
|
## Generator
|
169
185
|
|
170
186
|
This gem also includes a responders controller generator, so your scaffold can be customized
|
171
|
-
to use `respond_with` instead of default `respond_to` blocks.
|
172
|
-
|
187
|
+
to use `respond_with` instead of default `respond_to` blocks. From 2.1, you need to explicitly opt-in to use this generator by adding the following to your `config/application.rb`:
|
188
|
+
|
189
|
+
config.app_generators.scaffold_controller :responders_controller
|
190
|
+
|
191
|
+
## Failure handling
|
192
|
+
|
193
|
+
Responders don't use `valid?` to check for errors in models to figure out if
|
194
|
+
the request was successfull or not, and relies on your controllers to call
|
195
|
+
`save` or `create` to trigger the validations.
|
196
|
+
|
197
|
+
```ruby
|
198
|
+
def create
|
199
|
+
@widget = Widget.new(widget_params)
|
200
|
+
# @widget will be a valid record for responders, as we haven't called `save`
|
201
|
+
# on it, and will always redirect to the `widgets_path`.
|
202
|
+
respond_with @widget, location: -> { widgets_path }
|
203
|
+
end
|
204
|
+
```
|
205
|
+
|
206
|
+
Responders will check if the `errors` object in your model is empty or not. Take
|
207
|
+
this in consideration when implementing different actions or writing test
|
208
|
+
assertions on this behavior for your controllers.
|
209
|
+
|
210
|
+
```ruby
|
211
|
+
def create
|
212
|
+
@widget = Widget.new(widget_params)
|
213
|
+
@widget.errors.add(:base, :invalid)
|
214
|
+
# `respond_with` will render the `new` template again.
|
215
|
+
respond_with @widget
|
216
|
+
end
|
217
|
+
```
|
218
|
+
|
219
|
+
## Verifying request formats
|
220
|
+
|
221
|
+
`respond_with` will raise an `ActionController::UnknownFormat` if the request
|
222
|
+
mime type was not configured through the class level `respond_to`, but the
|
223
|
+
action will still be executed and any side effects (like creating a new record)
|
224
|
+
will still occur. To raise the `UnknownFormat` exception before your action
|
225
|
+
is invoked you can set the `verify_request_format!` method as a `before_action`
|
226
|
+
on your controller.
|
227
|
+
|
228
|
+
```ruby
|
229
|
+
class WidgetsController < ApplicationController
|
230
|
+
respond_to :json
|
231
|
+
before_action :verify_request_format!
|
232
|
+
|
233
|
+
# POST /widgets.html won't reach the `create` action.
|
234
|
+
def create
|
235
|
+
widget = Widget.create(widget_params)
|
236
|
+
respond_with widget
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
```
|
173
241
|
|
174
242
|
## Examples
|
175
243
|
|
176
244
|
Want more examples ? Check out this blog posts:
|
177
245
|
|
178
|
-
* [One in Three: Inherited Resources, Has Scope and Responders](http://blog.plataformatec.com.br/2009/12/one-in-three-inherited-resources-has-scope-and-responders/)
|
179
246
|
* [Embracing REST with mind, body and soul](http://blog.plataformatec.com.br/2009/08/embracing-rest-with-mind-body-and-soul/)
|
180
247
|
* [Three reasons to love ActionController::Responder](http://weblog.rubyonrails.org/2009/8/31/three-reasons-love-responder/)
|
181
|
-
* [My five favorite things about Rails 3](http://www.engineyard.com/blog/2009/my-five-favorite-things-about-rails-3
|
248
|
+
* [My five favorite things about Rails 3](http://www.engineyard.com/blog/2009/my-five-favorite-things-about-rails-3)
|
182
249
|
|
183
250
|
## Bugs and Feedback
|
184
251
|
|
@@ -186,4 +253,4 @@ If you discover any bugs or want to drop a line, feel free to create an issue on
|
|
186
253
|
|
187
254
|
http://github.com/plataformatec/responders/issues
|
188
255
|
|
189
|
-
MIT License. Copyright 2009-
|
256
|
+
MIT License. Copyright 2009-2016 Plataformatec. http://plataformatec.com.br
|
@@ -40,14 +40,14 @@ module ActionController #:nodoc:
|
|
40
40
|
only_actions = Array(options.delete(:only)).map(&:to_s)
|
41
41
|
except_actions = Array(options.delete(:except)).map(&:to_s)
|
42
42
|
|
43
|
-
|
43
|
+
hash = mimes_for_respond_to.dup
|
44
44
|
mimes.each do |mime|
|
45
45
|
mime = mime.to_sym
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
hash[mime] = {}
|
47
|
+
hash[mime][:only] = only_actions unless only_actions.empty?
|
48
|
+
hash[mime][:except] = except_actions unless except_actions.empty?
|
49
49
|
end
|
50
|
-
self.mimes_for_respond_to =
|
50
|
+
self.mimes_for_respond_to = hash.freeze
|
51
51
|
end
|
52
52
|
|
53
53
|
# Clear all mime types in <tt>respond_to</tt>.
|
@@ -175,7 +175,9 @@ module ActionController #:nodoc:
|
|
175
175
|
# Also, a hash passed to +respond_with+ immediately after the specified
|
176
176
|
# resource(s) is interpreted as a set of options relevant to all
|
177
177
|
# formats. Any option accepted by +render+ can be used, e.g.
|
178
|
+
#
|
178
179
|
# respond_with @people, status: 200
|
180
|
+
#
|
179
181
|
# However, note that these options are ignored after an unsuccessful attempt
|
180
182
|
# to save a resource, e.g. when automatically rendering <tt>:new</tt>
|
181
183
|
# after a post request.
|
@@ -191,10 +193,10 @@ module ActionController #:nodoc:
|
|
191
193
|
"formats your controller responds to in the class level."
|
192
194
|
end
|
193
195
|
|
194
|
-
mimes = collect_mimes_from_class_level
|
196
|
+
mimes = collect_mimes_from_class_level
|
195
197
|
collector = ActionController::MimeResponds::Collector.new(mimes, request.variant)
|
196
198
|
block.call(collector) if block_given?
|
197
|
-
|
199
|
+
|
198
200
|
if format = collector.negotiate_format(request)
|
199
201
|
_process_format(format)
|
200
202
|
options = resources.size == 1 ? {} : resources.extract_options!
|
@@ -206,7 +208,24 @@ module ActionController #:nodoc:
|
|
206
208
|
end
|
207
209
|
end
|
208
210
|
|
209
|
-
|
211
|
+
protected
|
212
|
+
|
213
|
+
# Before action callback that can be used to prevent requests that do not
|
214
|
+
# match the mime types defined through <tt>respond_to</tt> from being executed.
|
215
|
+
#
|
216
|
+
# class PeopleController < ApplicationController
|
217
|
+
# respond_to :html, :xml, :json
|
218
|
+
#
|
219
|
+
# before_action :verify_request_format!
|
220
|
+
# end
|
221
|
+
def verify_request_format!
|
222
|
+
mimes = collect_mimes_from_class_level
|
223
|
+
collector = ActionController::MimeResponds::Collector.new(mimes, request.variant)
|
224
|
+
|
225
|
+
unless collector.negotiate_format(request)
|
226
|
+
raise ActionController::UnknownFormat
|
227
|
+
end
|
228
|
+
end
|
210
229
|
|
211
230
|
# Collect mimes declared in the class method respond_to valid for the
|
212
231
|
# current action.
|
@@ -226,4 +245,4 @@ module ActionController #:nodoc:
|
|
226
245
|
end
|
227
246
|
end
|
228
247
|
end
|
229
|
-
end
|
248
|
+
end
|
@@ -182,10 +182,12 @@ module ActionController #:nodoc:
|
|
182
182
|
# responds to :to_format and display it.
|
183
183
|
#
|
184
184
|
def to_format
|
185
|
-
if get?
|
185
|
+
if !get? && has_errors? && !response_overridden?
|
186
|
+
display_errors
|
187
|
+
elsif has_view_rendering? || response_overridden?
|
186
188
|
default_render
|
187
189
|
else
|
188
|
-
|
190
|
+
api_behavior
|
189
191
|
end
|
190
192
|
rescue ActionView::MissingTemplate
|
191
193
|
api_behavior
|
@@ -233,7 +235,7 @@ module ActionController #:nodoc:
|
|
233
235
|
if @default_response
|
234
236
|
@default_response.call(options)
|
235
237
|
else
|
236
|
-
controller.
|
238
|
+
controller.render(options)
|
237
239
|
end
|
238
240
|
end
|
239
241
|
|
@@ -273,6 +275,10 @@ module ActionController #:nodoc:
|
|
273
275
|
Renderers::RENDERERS.include?(format)
|
274
276
|
end
|
275
277
|
|
278
|
+
def has_view_rendering?
|
279
|
+
controller.class.include? ActionView::Rendering
|
280
|
+
end
|
281
|
+
|
276
282
|
# By default, render the <code>:edit</code> action for HTML requests with errors, unless
|
277
283
|
# the verb was POST.
|
278
284
|
#
|
@@ -15,32 +15,8 @@ module Rails
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def orm_instance_update(params)
|
19
|
-
if orm_instance.respond_to?(:update)
|
20
|
-
orm_instance.update params
|
21
|
-
else
|
22
|
-
orm_instance.update_attributes params
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def controller_before_filter
|
27
|
-
if ActionController::Base.respond_to?(:before_action)
|
28
|
-
"before_action"
|
29
|
-
else
|
30
|
-
"before_filter"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
18
|
def attributes_params
|
35
|
-
|
36
|
-
"#{file_name}_params"
|
37
|
-
else
|
38
|
-
"params[:#{file_name}]"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def strong_parameters_defined?
|
43
|
-
defined?(ActionController::StrongParameters)
|
19
|
+
"#{singular_table_name}_params"
|
44
20
|
end
|
45
21
|
end
|
46
22
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<% if namespaced? -%>
|
2
|
+
require_dependency "<%= namespaced_file_path %>/application_controller"
|
3
|
+
|
4
|
+
<% end -%>
|
5
|
+
<% module_namespacing do -%>
|
6
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
7
|
+
before_action :set_<%= singular_table_name %>, only: [:show, :update, :destroy]
|
8
|
+
|
9
|
+
respond_to :json
|
10
|
+
|
11
|
+
<% unless options[:singleton] -%>
|
12
|
+
def index
|
13
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
14
|
+
respond_with(@<%= plural_table_name %>)
|
15
|
+
end
|
16
|
+
<% end -%>
|
17
|
+
|
18
|
+
def show
|
19
|
+
respond_with(@<%= singular_table_name %>)
|
20
|
+
end
|
21
|
+
|
22
|
+
def create
|
23
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, attributes_params) %>
|
24
|
+
<%= "flash[:notice] = '#{class_name} was successfully created.' if " if flash? %>@<%= orm_instance.save %>
|
25
|
+
respond_with(@<%= singular_table_name %>)
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
<%= "flash[:notice] = '#{class_name} was successfully updated.' if " if flash? %>@<%= orm_instance.update(attributes_params) %>
|
30
|
+
respond_with(@<%= singular_table_name %>)
|
31
|
+
end
|
32
|
+
|
33
|
+
def destroy
|
34
|
+
@<%= orm_instance.destroy %>
|
35
|
+
respond_with(@<%= singular_table_name %>)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def set_<%= singular_table_name %>
|
40
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
41
|
+
end
|
42
|
+
|
43
|
+
def <%= "#{singular_table_name}_params" %>
|
44
|
+
<%- if attributes_names.empty? -%>
|
45
|
+
params[:<%= singular_table_name %>]
|
46
|
+
<%- else -%>
|
47
|
+
params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
|
48
|
+
<%- end -%>
|
49
|
+
end
|
50
|
+
end
|
51
|
+
<% end -%>
|
@@ -1,6 +1,10 @@
|
|
1
|
+
<% if namespaced? -%>
|
2
|
+
require_dependency "<%= namespaced_file_path %>/application_controller"
|
3
|
+
|
4
|
+
<% end -%>
|
1
5
|
<% module_namespacing do -%>
|
2
6
|
class <%= controller_class_name %>Controller < ApplicationController
|
3
|
-
|
7
|
+
before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
|
4
8
|
|
5
9
|
respond_to :html
|
6
10
|
|
@@ -30,7 +34,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
30
34
|
end
|
31
35
|
|
32
36
|
def update
|
33
|
-
<%= "flash[:notice] = '#{class_name} was successfully updated.' if " if flash? %>@<%=
|
37
|
+
<%= "flash[:notice] = '#{class_name} was successfully updated.' if " if flash? %>@<%= orm_instance.update(attributes_params) %>
|
34
38
|
respond_with(@<%= singular_table_name %>)
|
35
39
|
end
|
36
40
|
|
@@ -43,7 +47,6 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
43
47
|
def set_<%= singular_table_name %>
|
44
48
|
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
45
49
|
end
|
46
|
-
<%- if strong_parameters_defined? -%>
|
47
50
|
|
48
51
|
def <%= "#{singular_table_name}_params" %>
|
49
52
|
<%- if attributes_names.empty? -%>
|
@@ -52,6 +55,5 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
52
55
|
params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
|
53
56
|
<%- end -%>
|
54
57
|
end
|
55
|
-
<%- end -%>
|
56
58
|
end
|
57
59
|
<% end -%>
|
@@ -18,6 +18,14 @@ end
|
|
18
18
|
RUBY
|
19
19
|
end
|
20
20
|
|
21
|
+
def update_application
|
22
|
+
inject_into_class "config/application.rb", "Application", <<-RUBY
|
23
|
+
# Use the responders controller from the responders gem
|
24
|
+
config.app_generators.scaffold_controller :responders_controller
|
25
|
+
|
26
|
+
RUBY
|
27
|
+
end
|
28
|
+
|
21
29
|
def update_application_controller
|
22
30
|
prepend_file "app/controllers/application_controller.rb", %{require "application_responder"\n\n}
|
23
31
|
inject_into_class "app/controllers/application_controller.rb", "ApplicationController", <<-RUBY
|
data/lib/responders.rb
CHANGED
@@ -19,12 +19,6 @@ module Responders
|
|
19
19
|
config.responders.flash_keys = [:notice, :alert]
|
20
20
|
config.responders.namespace_lookup = false
|
21
21
|
|
22
|
-
if config.respond_to?(:app_generators)
|
23
|
-
config.app_generators.scaffold_controller = :responders_controller
|
24
|
-
else
|
25
|
-
config.generators.scaffold_controller = :responders_controller
|
26
|
-
end
|
27
|
-
|
28
22
|
# Add load paths straight to I18n, so engines and application can overwrite it.
|
29
23
|
require 'active_support/i18n'
|
30
24
|
I18n.load_path << File.expand_path('../responders/locales/en.yml', __FILE__)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Responders
|
2
2
|
module LocationResponder
|
3
3
|
def self.included(_base)
|
4
|
-
ActiveSupport::Deprecation.warn "Responders::LocationResponder is enabled by default, "
|
4
|
+
ActiveSupport::Deprecation.warn "Responders::LocationResponder is enabled by default, " \
|
5
5
|
"no need to include it", caller
|
6
6
|
end
|
7
7
|
end
|
data/lib/responders/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: responders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.2.0
|
19
|
+
version: 4.2.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '5'
|
22
|
+
version: '5.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 4.2.0
|
29
|
+
version: 4.2.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '5'
|
32
|
+
version: '5.1'
|
33
33
|
description: A set of Rails responders to dry up your application
|
34
34
|
email: contact@plataformatec.com.br
|
35
35
|
executables: []
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- lib/action_controller/responder.rb
|
44
44
|
- lib/generators/rails/USAGE
|
45
45
|
- lib/generators/rails/responders_controller_generator.rb
|
46
|
+
- lib/generators/rails/templates/api_controller.rb
|
46
47
|
- lib/generators/rails/templates/controller.rb
|
47
48
|
- lib/generators/responders/install_generator.rb
|
48
49
|
- lib/responders.rb
|
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
74
|
version: '0'
|
74
75
|
requirements: []
|
75
76
|
rubyforge_project: responders
|
76
|
-
rubygems_version: 2.
|
77
|
+
rubygems_version: 2.5.1
|
77
78
|
signing_key:
|
78
79
|
specification_version: 4
|
79
80
|
summary: A set of Rails responders to dry up your application
|