Class: Tienda::VariantsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tienda/variants_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
# File 'app/controllers/tienda/variants_controller.rb', line 17

def create
  @variant = @product.variants.build(safe_params)
  if @variant.save
    redirect_to [@product, :variants], notice: t('tienda.variants.create_notice')
  else
    render action: "form"
  end
end

#destroyObject



38
39
40
41
# File 'app/controllers/tienda/variants_controller.rb', line 38

def destroy
  @variant.destroy
  redirect_to [@product, :variants], notice: t('tienda.variants.destroy_notice')
end

#editObject



26
27
28
# File 'app/controllers/tienda/variants_controller.rb', line 26

def edit
  render action: "form"
end

#indexObject



8
9
10
# File 'app/controllers/tienda/variants_controller.rb', line 8

def index
  @variants = @product.variants.ordered
end

#newObject



12
13
14
15
# File 'app/controllers/tienda/variants_controller.rb', line 12

def new
  @variant = @product.variants.build
  render action: "form"
end

#updateObject



30
31
32
33
34
35
36
# File 'app/controllers/tienda/variants_controller.rb', line 30

def update
  if @variant.update(safe_params)
    redirect_to edit_product_variant_path(@product, @variant), notice: t('tienda.variants.update_notice')
  else
    render action: "form"
  end
end