Skip to content

Commit

Permalink
Use AA::Resource::Name#param_key in form building
Browse files Browse the repository at this point in the history
  • Loading branch information
sindrenm committed Sep 11, 2014
1 parent 6472173 commit 2f60776
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/active_admin/resource/naming.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module ActiveAdmin
class Resource

module Naming
delegate :param_key, to: :resource_name

def resource_name
@resource_name ||= begin
as = @options[:as].gsub /\s/, '' if @options[:as]
Expand All @@ -26,16 +28,6 @@ def plural_resource_label(options = {})
default: resource_label.pluralize.titleize}
resource_name.translate defaults.merge options
end

# Forms use the model's original `param_key`, so we can't use our
# custom `resource_name` when the model's been renamed in ActiveAdmin.
def param_key
if resource_class.respond_to? :model_name
resource_class.model_name.param_key
else
resource_name.param_key
end
end
end

class Name < ActiveModel::Name
Expand Down

0 comments on commit 2f60776

Please sign in to comment.