Class: Ecom::Core::UnitCostsController
Instance Method Summary
collapse
#current_user, #logged_in?
Instance Method Details
#create ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'app/controllers/ecom/core/unit_costs_controller.rb', line 12
def create
unit_cost = UnitCost.new(unit_cost_params)
if unit_cost.save
render json: unit_cost, status: :created
else
render json: { success: false, errors: unit_cost.errors }, status: :unprocessable_entity
end
end
|
#index ⇒ Object
6
7
8
9
10
|
# File 'app/controllers/ecom/core/unit_costs_controller.rb', line 6
def index
unit_costs = UnitCost.where(active: true)
serialized = ActiveModelSerializers::SerializableResource.new(unit_costs)
render json: { success: true, data: serialized }
end
|