Module: Tomify::Concerns::Api::JSON

Extended by:
ActiveSupport::Concern
Includes:
Helpers
Included in:
Admin, Public
Defined in:
app/controllers/tomify/concerns/api/json.rb

Instance Method Summary collapse

Instance Method Details

#createObject



30
31
32
33
# File 'app/controllers/tomify/concerns/api/json.rb', line 30

def create
  create_record
  render json: { type: :success, data: data, message: "#{model_name} Created" }
end

#destroyObject



40
41
42
43
# File 'app/controllers/tomify/concerns/api/json.rb', line 40

def destroy
  destroy_record
  render json: { type: :danger, message: "#{model_name} Deleted" }
end

#indexObject



20
21
22
23
# File 'app/controllers/tomify/concerns/api/json.rb', line 20

def index
  find_records
  render json: { type: :success, data: data }
end

#showObject



25
26
27
28
# File 'app/controllers/tomify/concerns/api/json.rb', line 25

def show
  find_record
  render json: { type: :success, data: data }
end

#updateObject



35
36
37
38
# File 'app/controllers/tomify/concerns/api/json.rb', line 35

def update
  update_record
  render json: { type: :success, data: data, message: "#{model_name} Updated" }
end