Class: Admin::ScaffoldController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/scaffold_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/admin/scaffold_controller.rb', line 18

def create
    set_object current_resource_class.new(params[:"#{resource_name}"])
    
    if current_resource.respond_to?("administrator=")
      current_resource.administrator ||= current_administrator
    end
    
    current_resource.save
    respond_with(current_resource)
end

#destroyObject



35
36
37
38
# File 'app/controllers/admin/scaffold_controller.rb', line 35

def destroy
  current_resource.destroy
  respond_with(current_resource)
end

#editObject



15
16
# File 'app/controllers/admin/scaffold_controller.rb', line 15

def edit
end

#indexObject



6
7
8
9
# File 'app/controllers/admin/scaffold_controller.rb', line 6

def index
  @search = current_resource_class.search(params[:search])
  set_collection @search.page(params[:page] || 1)
end

#newObject



11
12
13
# File 'app/controllers/admin/scaffold_controller.rb', line 11

def new
   set_object current_resource_class.new  
end

#updateObject



29
30
31
32
33
# File 'app/controllers/admin/scaffold_controller.rb', line 29

def update
  current_resource.attributes = params[:"#{resource_name}"]
  current_resource.save
  respond_with(current_resource)
end