Sha256: 721a37f07a572c8bfe6edb11094d09d175fa329cb6f83c228a22fe60362caeda
Contents?: true
Size: 1017 Bytes
Versions: 2
Compression:
Stored size: 1017 Bytes
Contents
module Ecom module Core module Lookupable extend ActiveSupport::Concern included do before_action :set_clazz 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ecom_core-1.0.4 | app/controllers/concerns/ecom/core/lookupable.rb |
ecom_core-1.0.3 | app/controllers/concerns/ecom/core/lookupable.rb |