Class: Adminpanel::CategoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/adminpanel/categories_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#get_menu_elements, #handle_unverified_request, #set_model, #signed_in_user

Methods included from RouterHelper

#adminpanel_resources, #default_controllers, #find_resources, #menu_items, #resources_path

Methods included from RestActionsHelper

#show

Methods included from SessionsHelper

#current_user, #current_user=, #sign_in, #sign_out, #signed_in?

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/adminpanel/categories_controller.rb', line 16

def create
  create! do |success, failure|
    success.html do
      flash.now[:success] = I18n.t("action.save_success")
      # render "shared/index"
      redirect_to categories_path
    end
    failure.html do
      set_collections
      render "shared/new"
    end

    success.js do
       render :locals => {:category => resource }

    end
    failure.js do
      set_collections
      render "new", :locals => {:category => resource, :model => resource.model }, :formats => [:js]

    end
  end
end

#destroyObject



63
64
65
66
67
68
69
# File 'app/controllers/adminpanel/categories_controller.rb', line 63

def destroy
  destroy! do |format|
    format.html do
      redirect_to categories_path
    end
  end
end

#editObject



40
41
42
43
44
45
46
47
# File 'app/controllers/adminpanel/categories_controller.rb', line 40

def edit
  edit! do |format|
    format.html do
      set_collections
      render "shared/edit"
    end
  end
end

#indexObject



3
4
5
# File 'app/controllers/adminpanel/categories_controller.rb', line 3

def index
  @categories = Category.all
end

#newObject



7
8
9
10
11
12
13
# File 'app/controllers/adminpanel/categories_controller.rb', line 7

def new
  set_collections
  new! do |format|
    format.html { render "shared/new" }
    format.js {render :locals => {:category => resource, :model => params[:model]}}
  end
end

#updateObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/adminpanel/categories_controller.rb', line 49

def update
  update! do |success, failure|
    success.html do
      flash.now[:success] = I18n.t("action.save_success")
      # render "shared/index"
      redirect_to categories_path
    end
    failure.html do
      set_collections
      render "shared/edit"
    end
  end
end