Sha256: b48bd59f94177ff3003c86ffe0ffbd84c022b9aea99172645151a42997a19ac9
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module Ecom module Core module Lookupable extend ActiveSupport::Concern included do before_action :set_clazz, only: [:update] end def index render json: ResourceTypeSerializer.new(@clazz.all) end def create lookup = @clazz.new(lookup_params) if lookup.save render json: LookupSerializer.new(lookup), status: :created else render json: { success: false, errors: lookup.errors }, status: :unprocessable_entity end end def update lookup = @clazz.find(params[:id]) if lookup.update(lookup_params) render json: LookupSerializer.new(lookup) else render json: { success: false, errors: lookup.errors }, status: :unprocessable_entity end end private def set_clazz @clazz = "Ecom::Core::#{controller_name.classify}".constantize end def lookup_params params.require(:lookup).permit(:name) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ecom_core-1.0.2 | app/controllers/concerns/ecom/core/lookupable.rb |