Class: ClAdmin::ResourcesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/cl_admin/resources_controller.rb

Instance Method Summary collapse

Instance Method Details

#admin_resourceObject



35
36
37
# File 'app/controllers/cl_admin/resources_controller.rb', line 35

def admin_resource
  @admin_resource ||= ClAdmin::Resource.all.find{|r| r.path == resource_name_from_url}
end

#createObject



11
12
13
14
# File 'app/controllers/cl_admin/resources_controller.rb', line 11

def create
  @resource = resource_class.create(resource_params)
  redirect_to @resource, notice: "#{admin_resource.name} was successfully created."
end

#indexObject



3
4
5
# File 'app/controllers/cl_admin/resources_controller.rb', line 3

def index
  admin_resource
end

#newObject



7
8
9
# File 'app/controllers/cl_admin/resources_controller.rb', line 7

def new
  @resource = resource_class.new
end

#resourceObject



30
31
32
# File 'app/controllers/cl_admin/resources_controller.rb', line 30

def resource
  @resource ||= resource_class.find(params[:id])
end

#resource_classObject



20
21
22
# File 'app/controllers/cl_admin/resources_controller.rb', line 20

def resource_class
  @resource_class ||= admin_resource.model
end

#resourcesObject



25
26
27
# File 'app/controllers/cl_admin/resources_controller.rb', line 25

def resources
  @resources ||= resource_class.all
end

#showObject



16
17
18
# File 'app/controllers/cl_admin/resources_controller.rb', line 16

def show
  @resource = resource_class.find(params[:id])
end