Class: Adminpanel::CategoriesController

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

Instance Method Summary collapse

Methods included from FacebookActions

#fb_choose_page, #fb_publish, #fb_save_token

Methods included from GalleryzableActions

#move_better, #move_worst

Methods included from RestActions

#show

Methods included from SessionsHelper

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

Instance Method Details

#create ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/adminpanel/categories_controller.rb', line 20

def create
  params.merge({:model_name => params[:model_name]}) if params[:model_name].present?
  params.merge({:model => params[:model]}) if params[:model].present?
  params.merge({:currentcontroller => params[:currentcontroller]}) if params[:currentcontroller].present?
  params.merge({:belongs_request => params[:belongs_request]}) if params[:belongs_request].present?

  create! do |success, failure|
    success.html do
      flash[:success] = I18n.t("action.save_success")
      redirect_to categories_path
    end
    failure.html do
      set_collections
      render 'shared/new'
    end
    success.js do
      if params[:currentcontroller].to_s == 'adminpanel/categories'
        render 'create', :locals => {:category => resource}
      elsif params[:belongs_request].present?
        render 'shared/create_belongs_to'
      else
        render 'shared/create_has_many'
      end
    end
    failure.js do
      set_collections
      render "new"

    end
  end
end

#destroy ⇒ Object



75
76
77
78
79
80
81
# File 'app/controllers/adminpanel/categories_controller.rb', line 75

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

#edit ⇒ Object



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

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

#index ⇒ Object



5
6
7
# File 'app/controllers/adminpanel/categories_controller.rb', line 5

def index
  @categories = Category.all
end

#new ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'app/controllers/adminpanel/categories_controller.rb', line 9

def new
  set_collections
  new! do |format|
    format.html { render "shared/new" }
    format.js do
      render
    end
  end
end

#update ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/adminpanel/categories_controller.rb', line 61

def update
  update! do |success, failure|
    success.html do
      flash[: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