Module: Character::ModelClassConcern

Extended by:
ActiveSupport::Concern
Included in:
ApiController
Defined in:
app/controllers/concerns/character/model_class_concern.rb

Instance Method Summary collapse

Instance Method Details

#form_attributes_namespaceObject

form_attributes_namespace is used while form processing in update and create methods



23
24
25
26
27
# File 'app/controllers/concerns/character/model_class_concern.rb', line 23

def form_attributes_namespace
  @form_attributes_namespace ||= begin
    model_class.name.underscore.gsub('/', '_').to_sym
  end
end

#model_classObject

model class to be used in actions, class name is defined

in URL with a slag where - replaced by

e.g. Character::BlogPost would be /api/Character-BlogPost/new



14
15
16
17
18
# File 'app/controllers/concerns/character/model_class_concern.rb', line 14

def model_class
  @model_class ||= begin
    model_slug.gsub('-', '::').constantize
  end
end

#model_slugObject



4
5
6
7
8
# File 'app/controllers/concerns/character/model_class_concern.rb', line 4

def model_slug
  @model_slug ||= begin
    params[:model_slug]
  end
end