Commit 2917f48ff29734367f890f532a60b884f469e3d9
1 parent
176093a3
Exists in
master
and in
29 other branches
plugins: fix regression with controller filters
can't call Array() on a hash because it will generate an array of [key, value] arrays.
Showing
1 changed file
with
5 additions
and
2 deletions
Show diff stats
lib/noosfero/plugin.rb
... | ... | @@ -102,8 +102,11 @@ class Noosfero::Plugin |
102 | 102 | end |
103 | 103 | end |
104 | 104 | |
105 | - def add_controller_filters controller_class, plugin, filters | |
106 | - Array(filters).each do |plugin_filter| | |
105 | + def add_controller_filters(controller_class, plugin, filters) | |
106 | + unless filters.is_a?(Array) | |
107 | + filters = [filters] | |
108 | + end | |
109 | + filters.each do |plugin_filter| | |
107 | 110 | filter_method = (plugin.name.underscore.gsub('/','_') + '_' + plugin_filter[:method_name]).to_sym |
108 | 111 | controller_class.send(plugin_filter[:type], filter_method, (plugin_filter[:options] || {})) |
109 | 112 | controller_class.send(:define_method, filter_method) do | ... | ... |