Module: Ecom::Core::Lookupable

Extended by:
ActiveSupport::Concern
Defined in:
app/controllers/concerns/ecom/core/lookupable.rb

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
# File 'app/controllers/concerns/ecom/core/lookupable.rb', line 14

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

#indexObject



10
11
12
# File 'app/controllers/concerns/ecom/core/lookupable.rb', line 10

def index
  render json: LookupSerializer.new(@clazz.all)
end

#updateObject



23
24
25
26
27
28
29
30
# File 'app/controllers/concerns/ecom/core/lookupable.rb', line 23

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