Class: Comable::Admin::VariantsController
Instance Method Summary
collapse
#current_ability, #respond_to_export_with
Instance Method Details
#create ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'app/controllers/comable/admin/variants_controller.rb', line 29
def create
if @variant.save
redirect_to comable.admin_product_variant_path(@product, @variant), notice: Comable.t('successful')
else
flash.now[:alert] = Comable.t('failure')
render :new
end
end
|
#destroy ⇒ Object
50
51
52
53
|
# File 'app/controllers/comable/admin/variants_controller.rb', line 50
def destroy
@variant.destroy
redirect_to comable.admin_product_path(@product), notice: Comable.t('successful')
end
|
#edit ⇒ Object
38
39
|
# File 'app/controllers/comable/admin/variants_controller.rb', line 38
def edit
end
|
#index ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'app/controllers/comable/admin/variants_controller.rb', line 13
def index
@q = @variants.ransack(params[:q])
@variants = @q.result.includes(:product).page(params[:page]).accessible_by(current_ability).by_newest
respond_to do |format|
format.json { render json: @variants }
end
end
|
#new ⇒ Object
26
27
|
# File 'app/controllers/comable/admin/variants_controller.rb', line 26
def new
end
|
#show ⇒ Object
22
23
24
|
# File 'app/controllers/comable/admin/variants_controller.rb', line 22
def show
render :edit
end
|
#update ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'app/controllers/comable/admin/variants_controller.rb', line 41
def update
if @variant.update_attributes(variant_params)
redirect_to comable.admin_product_variant_path(@product, @variant), notice: Comable.t('successful')
else
flash.now[:alert] = Comable.t('failure')
render :edit
end
end
|