Class: Backend::ParcelItemsController

Inherits:
BaseController show all
Defined in:
app/controllers/backend/parcel_items_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#current_theme

Instance Method Summary collapse

Methods inherited from BaseController

accounts_range_crit, crit_params, journal_entries_states_crit, journal_period_crit, journals_crit, search_conditions

Methods inherited from ApplicationController

#after_sign_in_path_for, #authorized?, human_action_name, #human_action_name

Instance Method Details

#newObject


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/backend/parcel_items_controller.rb', line 21

def new
  if request.xhr? && params[:variant_id]
    unless @parcel = Parcel.find_by(id: params[:parcel_id])
      @parcel = Parcel.new
    end
    return unless variant = find_and_check(:product_nature_variant, params[:variant_id])
    params[:external] ||= false
    @parcel.items.build(product_nature_variant_id: variant.id) # (id: rand(1_000_000_000))
    render partial: 'nested_form'
  else
    redirect_to backend_root_path
  end
end