Class: Neo4j::MetaModel::Meta::ModelsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/neo4j/meta_model/meta/models_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



32
33
34
35
36
37
38
# File 'app/controllers/neo4j/meta_model/meta/models_controller.rb', line 32

def create
  model = Model.create(model_params)

  create_models

  render json: model
end

#destroyObject



51
52
53
54
55
56
57
# File 'app/controllers/neo4j/meta_model/meta/models_controller.rb', line 51

def destroy
  @model.destroy

  create_models

  render json: nil
end

#editObject



28
29
30
# File 'app/controllers/neo4j/meta_model/meta/models_controller.rb', line 28

def edit
  @models = Model.all.order(:name)
end

#hierarchyObject



14
15
16
17
18
# File 'app/controllers/neo4j/meta_model/meta/models_controller.rb', line 14

def hierarchy
  respond_to do |format|
    format.json { render json: Model.all.hierarchically }
  end
end

#indexObject



7
8
9
10
11
12
# File 'app/controllers/neo4j/meta_model/meta/models_controller.rb', line 7

def index
  respond_to do |format|
    format.html { @hierarchy = Model.all.hierarchically }
    format.json { render json: Model.all }
  end
end

#showObject



20
21
22
23
24
25
26
# File 'app/controllers/neo4j/meta_model/meta/models_controller.rb', line 20

def show
  respond_to do |format|
    format.json do
      render json: @model
    end
  end
end

#updateObject



40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/neo4j/meta_model/meta/models_controller.rb', line 40

def update
  model_params.each do |key, value|
    @model.send("#{key}=", value)
  end
  @model.save

  create_models

  render json: @model
end