Class: Postnhost::CategoryVariantsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Postnhost::CategoryVariantsController
- Defined in:
- app/controllers/postnhost/category_variants_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/postnhost/category_variants_controller.rb', line 25 def create @category_variant = @category.category_variants.new(variant_params) if @category_variant.save redirect_to category_variants_path(@category), notice: "Translation was successfully created." else render :new, status: :unprocessable_content end end |
#destroy ⇒ Object
43 44 45 46 |
# File 'app/controllers/postnhost/category_variants_controller.rb', line 43 def destroy @category_variant.destroy redirect_to category_variants_path(@category), notice: "Translation was successfully deleted." end |
#edit ⇒ Object
23 |
# File 'app/controllers/postnhost/category_variants_controller.rb', line 23 def edit; end |
#index ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/controllers/postnhost/category_variants_controller.rb', line 10 def index @variants = @category.category_variants.includes(:language).order(:created_at) @available_languages = Postnhost::Language.where.not(id: @category.category_variants.select(:language_id)) default_language = Postnhost::Language.blog_default @available_languages = @available_languages.where.not(id: default_language.id) if default_language.present? end |
#new ⇒ Object
18 19 20 21 |
# File 'app/controllers/postnhost/category_variants_controller.rb', line 18 def new @category_variant = @category.category_variants.new @category_variant.language = Postnhost::Language.find_by(id: params[:language_id]) if params[:language_id] end |
#update ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/controllers/postnhost/category_variants_controller.rb', line 35 def update if @category_variant.update(variant_params) redirect_to category_variants_path(@category), notice: "Translation was successfully updated." else render :edit, status: :unprocessable_content end end |