Class: Databaseformalizer::AttrDefsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/databaseformalizer/attr_defs_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /attr_defs POST /attr_defs.json



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/databaseformalizer/attr_defs_controller.rb', line 43

def create
  @attr_def = AttrDef.new(params[:databaseformalizer_attr_def])
  if @attr_def.label == ""
    @attr_def.label = @attr_def.attr_def_name
  end
  
  if params[:databaseformalizer_attr_def]['dataType'] == "entityDef"
    @attr_def.child_entity_def_name=params[:databaseformalizer_attr_def]['child_entity_def_name']
  else
    @attr_def.child_entity_def_name=nil
  end
  
  respond_to do |format|
    if @attr_def.save
      format.html { redirect_to @attr_def, notice: 'Attr def was successfully created.' }
      format.json { render json: @attr_def, status: :created, location: @attr_def }
    else
      format.html { render action: "new" }
      format.json { render json: @attr_def.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /attr_defs/1 DELETE /attr_defs/1.json



88
89
90
91
92
93
94
95
96
# File 'app/controllers/databaseformalizer/attr_defs_controller.rb', line 88

def destroy
  @attr_def = AttrDef.find(params[:id])
  @attr_def.destroy
  
  respond_to do |format|
    format.html { redirect_to databaseformalizer_attr_defs_url }
    format.json { head :no_content }
  end
end

#editObject

GET /attr_defs/1/edit



37
38
39
# File 'app/controllers/databaseformalizer/attr_defs_controller.rb', line 37

def edit
  @attr_def = AttrDef.find(params[:id])
end

#indexObject

GET /attr_defs GET /attr_defs.json



5
6
7
8
9
10
11
12
# File 'app/controllers/databaseformalizer/attr_defs_controller.rb', line 5

def index
  @attr_defs = AttrDef.all
  
  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @attr_defs }
  end
end

#newObject

GET /attr_defs/new GET /attr_defs/new.json



27
28
29
30
31
32
33
34
# File 'app/controllers/databaseformalizer/attr_defs_controller.rb', line 27

def new
  @attr_def = AttrDef.new
  
  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @attr_def }
  end
end

#showObject

GET /attr_defs/1 GET /attr_defs/1.json



16
17
18
19
20
21
22
23
# File 'app/controllers/databaseformalizer/attr_defs_controller.rb', line 16

def show
  @attr_def = AttrDef.find(params[:id])
  
  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @attr_def }
  end
end

#updateObject

PUT /attr_defs/1 PUT /attr_defs/1.json



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/controllers/databaseformalizer/attr_defs_controller.rb', line 68

def update
  @attr_def = AttrDef.find(params[:id])
  if params[:databaseformalizer_attr_def]['dataType'] == "entityDef"
    @attr_def.child_entity_def_name=params[:databaseformalizer_attr_def]['child_entity_def_name']
  else
    @attr_def.child_entity_def_name=nil
  end
  respond_to do |format|
    if @attr_def.update_attributes(params[:databaseformalizer_attr_def])
      format.html { redirect_to @attr_def, notice: 'Attr def was successfully updated.'}
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @attr_def.errors, status: :unprocessable_entity }
    end
  end
end