Class: Databaseformalizer::EntitiesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Databaseformalizer::EntitiesController
- Includes:
- Databaseformalizer
- Defined in:
- app/controllers/databaseformalizer/entities_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /entities POST /entities.json.
-
#destroy ⇒ Object
DELETE /entities/1 DELETE /entities/1.json.
-
#edit ⇒ Object
GET /entities/1/edit.
-
#index ⇒ Object
GET /entities GET /entities.json.
-
#new ⇒ Object
GET /entities/new GET /entities/new.json.
-
#show ⇒ Object
GET /entities/1 GET /entities/1.json.
-
#update ⇒ Object
PUT /entities/1 PUT /entities/1.json.
Instance Method Details
#create ⇒ Object
POST /entities POST /entities.json
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/databaseformalizer/entities_controller.rb', line 56 def create @entity = Entity.new(params[:databaseformalizer_entity]) @entity.attr_vals.clear EntitiesHelper.setAttrVals(params[:attr_vals], @entity) respond_to do |format| if @entity.save format.html { redirect_to @entity, notice: 'Entity was successfully created.' } format.json { render json: @entity, status: :created, location: @entity } else format.html { render action: "new" } format.json { render json: @entity.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /entities/1 DELETE /entities/1.json
93 94 95 96 97 98 99 100 101 102 |
# File 'app/controllers/databaseformalizer/entities_controller.rb', line 93 def destroy @entity = Entity.find(params[:id]) @entity.destroy respond_to do |format| format.html { redirect_to databaseformalizer_entities_url } format.json { head :no_content } end end |
#edit ⇒ Object
GET /entities/1/edit
49 50 51 52 |
# File 'app/controllers/databaseformalizer/entities_controller.rb', line 49 def edit @entity = Entity.find(params[:id]) @all_entityDefs = EntityDef.all end |
#index ⇒ Object
GET /entities GET /entities.json
7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/databaseformalizer/entities_controller.rb', line 7 def index @entities = Entity.find(:all, :limit=>100) EntitiesHelper.setModelGraph("public/UMLmodel.png") respond_to do |format| format.html # index.html.erb format.json { render json: @entities } end end |
#new ⇒ Object
GET /entities/new GET /entities/new.json
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/databaseformalizer/entities_controller.rb', line 30 def new @entity = Entity.new if params[:entity_def] != nil @all_entityDefs = EntityDef.find_all_by_entity_def_name(params[:entity_def]) @entity.entity_def = @all_entityDefs.first @type = params[:entity_def] else @all_entityDefs = EntityDef.all @type = "Entity" end respond_to do |format| format.html # new.html.erbe format.json { render json: @entity } format.js { @entity } end end |
#show ⇒ Object
GET /entities/1 GET /entities/1.json
19 20 21 22 23 24 25 26 |
# File 'app/controllers/databaseformalizer/entities_controller.rb', line 19 def show @entity = Entity.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @entity } end end |
#update ⇒ Object
PUT /entities/1 PUT /entities/1.json
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/controllers/databaseformalizer/entities_controller.rb', line 74 def update @entity = Entity.find(params[:id]) @entity.attr_vals.clear EntitiesHelper.setAttrVals(params[:attr_vals], @entity) @entity.attributes = params[:databaseformalizer_entity] respond_to do |format| if @entity.save format.html { redirect_to @entity, notice: 'Entity was successfully updated.'} format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @entity.errors, status: :unprocessable_entity } end end end |