Class: RailsAdmin::ApplicationController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/rails_admin/application_controller.rb

Direct Known Subclasses

MainController

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#abstract_modelObject (readonly)

Returns the value of attribute abstract_model.



19
20
21
# File 'app/controllers/rails_admin/application_controller.rb', line 19

def abstract_model
  @abstract_model
end

#model_configObject (readonly)

Returns the value of attribute model_config.



19
20
21
# File 'app/controllers/rails_admin/application_controller.rb', line 19

def model_config
  @model_config
end

#objectObject (readonly)

Returns the value of attribute object.



19
20
21
# File 'app/controllers/rails_admin/application_controller.rb', line 19

def object
  @object
end

Instance Method Details

#get_modelObject



21
22
23
24
25
26
# File 'app/controllers/rails_admin/application_controller.rb', line 21

def get_model
  @model_name = to_model_name(params[:model_name])
  raise RailsAdmin::ModelNotFound unless (@abstract_model = RailsAdmin::AbstractModel.new(@model_name))
  raise RailsAdmin::ModelNotFound if (@model_config = @abstract_model.config).excluded?
  @properties = @abstract_model.properties
end

#get_objectObject



28
29
30
# File 'app/controllers/rails_admin/application_controller.rb', line 28

def get_object
  raise RailsAdmin::ObjectNotFound unless (@object = @abstract_model.get(params[:id]))
end

#to_model_name(param) ⇒ Object



32
33
34
# File 'app/controllers/rails_admin/application_controller.rb', line 32

def to_model_name(param)
  model_name = param.split("~").map(&:camelize).join("::")
end