Class: Admin::BrandsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

Create a Brand

Params

  • brand = Hash of Brand’s attributes



25
26
27
28
29
30
31
32
33
# File 'app/controllers/admin/brands_controller.rb', line 25

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

#destroyObject

Destroy a Brand

Params

  • id = Brand’s id



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/controllers/admin/brands_controller.rb', line 55

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

#editObject



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

def edit
  @brand.comments.build if @brand.comments.empty?
end

#indexObject



6
7
8
9
10
11
12
13
14
# File 'app/controllers/admin/brands_controller.rb', line 6

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

#newObject

end



18
19
20
# File 'app/controllers/admin/brands_controller.rb', line 18

def new
  @brand.comments.build if @brand.comments.empty?
end

#updateObject

Update a Brand

Params

  • id = Brand’s id



42
43
44
45
46
47
48
49
50
# File 'app/controllers/admin/brands_controller.rb', line 42

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

#urlObject



69
70
71
# File 'app/controllers/admin/brands_controller.rb', line 69

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