Sha256: fe561a231157bf482e5fd7b7ebc474a1c09e4eb070654801f1429eb6d239ecee

Contents?: true

Size: 954 Bytes

Versions: 3

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true

require_dependency "vimo/application_controller"

module Vimo
  class EntitiesController < ApplicationController
    skip_before_action :verify_authenticity_token
    before_action :find_entity, only: [:show, :update, :destroy]

    def index
      @entities = entities_scope.page(page).per(per_page)
      respond_with @entities
    end

    def show
      respond_with @entity
    end

    def create
      @entity = entities_scope.create(entity_params)
      respond_with @entity
    end

    def update
      @entity.update(entity_params)
      respond_with @entity
    end

    def destroy
      @entity.destroy
      respond_with @entity
    end

    private

    def find_entity
      @entity = entities_scope.find(params[:id])
    end

    def entity_params
      params.require(:entity).
        permit(:name, :system_name,
          fields_attributes: [:id, :name, :kind, :required, :_destroy])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vimo-0.1.3 app/controllers/vimo/entities_controller.rb
vimo-0.1.1 app/controllers/vimo/entities_controller.rb
vimo-0.1.0 app/controllers/vimo/entities_controller.rb