Sha256: 12cf7594594fce31bb41a7a6d79bd0a66ca9586ba572dba338a76537b27959d2
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_lookup, 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.1 | app/controllers/concerns/ecom/core/lookupable.rb |