responders 1.0.0.rc → 1.0.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 +3 -1
- data/MIT-LICENSE +1 -1
- data/README.md +6 -6
- data/lib/generators/rails/responders_controller_generator.rb +29 -1
- data/lib/generators/rails/templates/controller.rb +20 -7
- data/lib/responders/flash_responder.rb +1 -1
- data/lib/responders/version.rb +1 -1
- data/test/test_helper.rb +0 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 729b9991a4c4c71e5def865e458f1941283aa074
|
4
|
+
data.tar.gz: 2f866da6f3f9f07fbc21f87405e66fd8245e12c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 550177b2c6824672e37d78391dd9e96b8e36c12ffe5a570aa116737b33301287cb53dac1b304d84f022c3c5d30aa42de1d0cfa3fde93caf991e069908ad79682
|
7
|
+
data.tar.gz: 01b5e546b4c55e00d29865e0479e1ce2ced384a31f4108ed79617596473e357d1ca1b8752e015cb4ac242d9385b7998f02433b7d26cbc51ad9909b7c4db7f7b5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
## 1.0.0
|
1
|
+
## 1.0.0
|
2
2
|
|
3
|
+
* Improve controller generator to work closer to the Rails 4 one, and make it
|
4
|
+
compatible with strong parameters.
|
3
5
|
* Drop support for Rails 3.1 and Ruby 1.8, keep support for Rails 3.2
|
4
6
|
* Support for Rails 4.0 onward
|
5
7
|
* Fix flash message on destroy failure. Fixes #61
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright
|
1
|
+
Copyright 2009-2013 Plataforma Tecnologia. http://blog.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
@@ -4,7 +4,7 @@
|
|
4
4
|
[![Build Status](https://api.travis-ci.org/plataformatec/responders.png?branch=master)](http://travis-ci.org/plataformatec/responders)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/plataformatec/responders.png)](https://codeclimate.com/github/plataformatec/responders)
|
6
6
|
|
7
|
-
A set of responders modules to dry up your Rails 3+ app.
|
7
|
+
A set of responders modules to dry up your Rails 3.2+ app.
|
8
8
|
|
9
9
|
## Responders Types
|
10
10
|
|
@@ -131,14 +131,14 @@ You can pass in extra interpolation options for the translation by adding an `in
|
|
131
131
|
```ruby
|
132
132
|
class InvitationsController < ApplicationController
|
133
133
|
responders :flash, :http_cache
|
134
|
-
|
134
|
+
|
135
135
|
def create
|
136
136
|
@invitation = Invitation.create(params[:invitation])
|
137
137
|
respond_with @invitation
|
138
|
-
end
|
139
|
-
|
138
|
+
end
|
139
|
+
|
140
140
|
private
|
141
|
-
|
141
|
+
|
142
142
|
def interpolation_options
|
143
143
|
{ resource_name: @invitation.email }
|
144
144
|
end
|
@@ -168,4 +168,4 @@ If you discover any bugs or want to drop a line, feel free to create an issue on
|
|
168
168
|
|
169
169
|
http://github.com/plataformatec/responders/issues
|
170
170
|
|
171
|
-
MIT License. Copyright
|
171
|
+
MIT License. Copyright 2009-2013 Plataforma Tecnologia. http://blog.plataformatec.com.br
|
@@ -14,6 +14,34 @@ module Rails
|
|
14
14
|
Rails.application.config.responders.flash_keys.blank?
|
15
15
|
end
|
16
16
|
end
|
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
|
+
def attributes_params
|
35
|
+
if strong_parameters_defined?
|
36
|
+
"#{file_name}_params"
|
37
|
+
else
|
38
|
+
"params[:#{file_name}]"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def strong_parameters_defined?
|
43
|
+
defined?(ActionController::StrongParameters)
|
44
|
+
end
|
17
45
|
end
|
18
46
|
end
|
19
|
-
end
|
47
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
2
|
class <%= controller_class_name %>Controller < ApplicationController
|
3
|
+
<%= controller_before_filter %> :set_<%= file_name %>, only: [:show, :edit, :update, :destroy]
|
4
|
+
|
3
5
|
<% unless options[:singleton] -%>
|
4
6
|
def index
|
5
7
|
@<%= table_name %> = <%= orm_class.all(class_name) %>
|
@@ -8,7 +10,6 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
8
10
|
<% end -%>
|
9
11
|
|
10
12
|
def show
|
11
|
-
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
12
13
|
respond_with(@<%= file_name %>)
|
13
14
|
end
|
14
15
|
|
@@ -18,25 +19,37 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def edit
|
21
|
-
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
22
22
|
end
|
23
23
|
|
24
24
|
def create
|
25
|
-
@<%= file_name %> = <%= orm_class.build(class_name,
|
25
|
+
@<%= file_name %> = <%= orm_class.build(class_name, attributes_params) %>
|
26
26
|
<%= "flash[:notice] = '#{class_name} was successfully created.' if " if flash? %>@<%= orm_instance.save %>
|
27
27
|
respond_with(@<%= file_name %>)
|
28
28
|
end
|
29
29
|
|
30
30
|
def update
|
31
|
-
|
32
|
-
<%= "flash[:notice] = '#{class_name} was successfully updated.' if " if flash? %>@<%= orm_instance.update_attributes("params[:#{file_name}]") %>
|
31
|
+
<%= "flash[:notice] = '#{class_name} was successfully updated.' if " if flash? %>@<%= orm_instance_update(attributes_params) %>
|
33
32
|
respond_with(@<%= file_name %>)
|
34
33
|
end
|
35
34
|
|
36
35
|
def destroy
|
37
|
-
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
38
36
|
@<%= orm_instance.destroy %>
|
39
37
|
respond_with(@<%= file_name %>)
|
40
38
|
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def set_<%= file_name %>
|
42
|
+
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
43
|
+
end
|
44
|
+
<%- if strong_parameters_defined? -%>
|
45
|
+
|
46
|
+
def <%= "#{file_name}_params" %>
|
47
|
+
<%- if attributes_names.empty? -%>
|
48
|
+
params[:<%= file_name %>]
|
49
|
+
<%- else -%>
|
50
|
+
params.require(:<%= file_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
|
51
|
+
<%- end -%>
|
52
|
+
end
|
53
|
+
<%- end -%>
|
41
54
|
end
|
42
|
-
<% end -%>
|
55
|
+
<% end -%>
|
@@ -12,7 +12,7 @@ module Responders
|
|
12
12
|
# flash.actions.create.status
|
13
13
|
#
|
14
14
|
# The statuses by default are :notice (when the object can be created, updated
|
15
|
-
# or destroyed with success) and :alert (when the
|
15
|
+
# or destroyed with success) and :alert (when the object cannot be created
|
16
16
|
# or updated).
|
17
17
|
#
|
18
18
|
# On I18n, the resource_name given is available as interpolation option,
|
data/lib/responders/version.rb
CHANGED
data/test/test_helper.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: 1.0.0
|
4
|
+
version: 1.0.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: 2013-
|
11
|
+
date: 2013-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -74,12 +74,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
74
|
version: '0'
|
75
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
- - '
|
77
|
+
- - '>='
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
79
|
+
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project: responders
|
82
|
-
rubygems_version: 2.0.
|
82
|
+
rubygems_version: 2.0.6
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: A set of Rails responders to dry up your application
|