Skip to content

Commit

Permalink
Fix bug with route fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregschmit committed Apr 12, 2024
1 parent 2c7607f commit 6342f9b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/rest_framework/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ def self.parse_extra_actions(extra_actions, controller: nil)
# Symbolize keys (which also makes a copy so we don't mutate the original).
v = v.symbolize_keys
methods = v.delete(:methods)
if v.key?(:method)
methods = v.delete(:method)
end

# First, remove the route metadata.
metadata = v.delete(:metadata) || {}

# Add label to fields.
if controller && metadata[:fields]
metadata[:fields] = metadata[:fields].map { |f| [f, {}] }.to_h if f.is_a?(Array)
metadata[:fields] = metadata[:fields].map { |f|
[f, {}]
}.to_h if metadata[:fields].is_a?(Array)
metadata[:fields]&.each do |field, cfg|
cfg[:label] = controller.get_label(field) unless cfg[:label]
end
Expand Down

0 comments on commit 6342f9b

Please sign in to comment.