Sha256: 752f70295926ac3333feb9a4cf1ae52e250cae20326d85711ee27a508bb17343
Contents?: true
Size: 1011 Bytes
Versions: 39
Compression:
Stored size: 1011 Bytes
Contents
module Ecom module Core module Lookupable extend ActiveSupport::Concern included do before_action :set_clazz end def index render json: LookupSerializer.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
39 entries across 39 versions & 1 rubygems