Class: Kaui::TagDefinitionsController

Inherits:
EngineController show all
Defined in:
app/controllers/kaui/tag_definitions_controller.rb

Instance Method Summary collapse

Methods inherited from EngineController

#current_user

Methods included from ErrorHelper

#as_string

Instance Method Details

#createObject

POST /tag_definitions POST /tag_definitions.json



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/kaui/tag_definitions_controller.rb', line 48

def create
  @tag_definition = TagDefinition.new(params[:tag_definition])

  respond_to do |format|
    if @tag_definition.save
      format.html { redirect_to @tag_definition, :notice => 'Tag definition was successfully created.' }
      format.json { render :json => @tag_definition, :status => :created, :location => @tag_definition }
    else
      format.html { render :action => "new" }
      format.json { render :json => @tag_definition.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /tag_definitions/1 DELETE /tag_definitions/1.json



80
81
82
83
84
85
86
87
88
# File 'app/controllers/kaui/tag_definitions_controller.rb', line 80

def destroy
  @tag_definition = TagDefinition.find(params[:id])
  @tag_definition.destroy

  respond_to do |format|
    format.html { redirect_to tag_definitions_url }
    format.json { head :no_content }
  end
end

#editObject

GET /tag_definitions/1/edit



42
43
44
# File 'app/controllers/kaui/tag_definitions_controller.rb', line 42

def edit
  @tag_definition = TagDefinition.find(params[:id])
end

#indexObject

GET /tag_definitions GET /tag_definitions.json



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/kaui/tag_definitions_controller.rb', line 5

def index
  begin
    @tag_definitions = TagDefinition.all
  rescue => e
    flash[:error] = "Error while retrieving tag definitions: #{as_string(e)}"
    @tag_definitions = []
  end

  respond_to do |format|
    format.html # index.html.erb
    format.json { render :json => @tag_definitions }
  end
end

#newObject

GET /tag_definitions/new GET /tag_definitions/new.json



32
33
34
35
36
37
38
39
# File 'app/controllers/kaui/tag_definitions_controller.rb', line 32

def new
  @tag_definition = TagDefinition.new

  respond_to do |format|
    format.html # new.html.erb
    format.json { render :json => @tag_definition }
  end
end

#showObject

GET /tag_definitions/1 GET /tag_definitions/1.json



21
22
23
24
25
26
27
28
# File 'app/controllers/kaui/tag_definitions_controller.rb', line 21

def show
  @tag_definition = TagDefinition.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.json { render :json => @tag_definition }
  end
end

#updateObject

PUT /tag_definitions/1 PUT /tag_definitions/1.json



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/controllers/kaui/tag_definitions_controller.rb', line 64

def update
  @tag_definition = TagDefinition.find(params[:id])

  respond_to do |format|
    if @tag_definition.update_attributes(params[:tag_definition])
      format.html { redirect_to @tag_definition, :notice => 'Tag definition was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render :action => "edit" }
      format.json { render :json => @tag_definition.errors, :status => :unprocessable_entity }
    end
  end
end