Class: Admin::CategoriesController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/formol/admin/categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
# File 'app/controllers/formol/admin/categories_controller.rb', line 14

def create
  if category.save
    respond_with(category, :status => :created, :location => admin_categories_path)
  else
    respond_with(category, :status => :unprocessable_entity) do |format|
      format.html { render :new }
    end
  end
end

#destroyObject



38
39
40
41
42
# File 'app/controllers/formol/admin/categories_controller.rb', line 38

def destroy
  category.destroy
  
  respond_with(category, :location => admin_categories_path)
end

#editObject



24
25
26
# File 'app/controllers/formol/admin/categories_controller.rb', line 24

def edit
  category
end

#indexObject



6
7
8
# File 'app/controllers/formol/admin/categories_controller.rb', line 6

def index
  categories
end

#newObject



10
11
12
# File 'app/controllers/formol/admin/categories_controller.rb', line 10

def new
  category
end

#sortObject



44
45
46
47
48
# File 'app/controllers/formol/admin/categories_controller.rb', line 44

def sort
  Formol::Category.sort(params[:categories])
  
  render :nothing => true, :status => :ok
end

#updateObject



28
29
30
31
32
33
34
35
36
# File 'app/controllers/formol/admin/categories_controller.rb', line 28

def update
  if category.update_attributes(params[:category])
    respond_with(category, :location => admin_categories_path)
  else
    respond_with(category) do |format|
      format.html { render :edit }
    end
  end
end