Class: Admin::AttributesController

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

Overview

This Controller Manage Attributes and his association with Attribute Values

Instance Method Summary collapse

Instance Method Details

#access_methodObject



76
77
78
# File 'app/controllers/admin/attributes_controller.rb', line 76

def access_method
  render :text => Forgeos::url_generator(params[:access_method])
end

#createObject

Create an attribute

Params

  • attribute = Hash of attribute’s attributes



34
35
36
37
38
39
40
41
42
# File 'app/controllers/admin/attributes_controller.rb', line 34

def create
  if @attribute.save
    flash[:notice] = I18n.t('attribute.create.success').capitalize
    redirect_to([forgeos_commerce, :edit, :admin, @attribute])
  else
    flash[:error] = I18n.t('attribute.create.failed').capitalize
    render :action => :new
  end
end

#destroyObject

Destroy an attribute

Params

  • id = attribute’s id



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/controllers/admin/attributes_controller.rb', line 62

def destroy
  if @attribute.destroy
    flash[:notice] = I18n.t('attribute.destroy.success').capitalize
  else
    flash[:error] = I18n.t('attribute.destroy.failed').capitalize
  end
  respond_to do |wants|
    wants.html do
      redirect_to([forgeos_commerce, :admin, :attributes])
    end
    wants.js
  end
end

#duplicateObject



26
27
28
29
# File 'app/controllers/admin/attributes_controller.rb', line 26

def duplicate
  @attribute = @attribute.clone
  render :new
end

#editObject

Edit an attribute

Params

  • id = attribute’s id



47
48
# File 'app/controllers/admin/attributes_controller.rb', line 47

def edit
end

#indexObject

List attributes



10
11
12
13
14
15
16
17
18
# File 'app/controllers/admin/attributes_controller.rb', line 10

def index
  respond_to do |format|
    format.html
    format.json do
      sort
      render :layout => false
    end
  end
end

#newObject



23
24
# File 'app/controllers/admin/attributes_controller.rb', line 23

def new
end

#showObject



20
21
# File 'app/controllers/admin/attributes_controller.rb', line 20

def show
end

#updateObject



50
51
52
53
54
55
56
57
# File 'app/controllers/admin/attributes_controller.rb', line 50

def update
  if @attribute.update_attributes(params[:attribute])
    flash[:notice] = I18n.t('attribute.update.success').capitalize
  else
    flash[:error] = I18n.t('attribute.update.failed').capitalize
  end
  render :action => :edit
end