Class: Ems::TagsController

Inherits:
ApplicationController show all
Includes:
TagQueryBuilder
Defined in:
app/controllers/ems/tags_controller.rb

Instance Method Summary collapse

Methods included from TagQueryBuilder

#add_filter_for_like, #build_query_from_filters

Methods inherited from ApplicationController

#current_ability

Instance Method Details

#createObject

POST /tags POST /tags.json



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/ems/tags_controller.rb', line 50

def create
  @tag = Tag.new(params[:tag])

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

#destroyObject

DELETE /tags/1 DELETE /tags/1.json



82
83
84
85
86
87
88
89
90
# File 'app/controllers/ems/tags_controller.rb', line 82

def destroy
  @tag = Tag.find(params[:id])
  @tag.destroy

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

#editObject

GET /tags/1/edit



44
45
46
# File 'app/controllers/ems/tags_controller.rb', line 44

def edit
  @tag = Tag.find(params[:id])
end

#indexObject

GET /tags GET /tags.json



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/ems/tags_controller.rb', line 8

def index
  if params[:filters]
    @tags = build_query_from_filters Tag, params[:filters]
  else
    @tags = Tag.all
  end

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

#newObject

GET /tags/new GET /tags/new.json



34
35
36
37
38
39
40
41
# File 'app/controllers/ems/tags_controller.rb', line 34

def new
  @tag = Tag.new

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

#showObject

GET /tags/1 GET /tags/1.json



23
24
25
26
27
28
29
30
# File 'app/controllers/ems/tags_controller.rb', line 23

def show
  @tag = Tag.find(params[:id])

  respond_to do |format|
    format.html # edit.html.erb
    format.json { render json: @tag }
  end
end

#updateObject

PUT /tags/1 PUT /tags/1.json



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'app/controllers/ems/tags_controller.rb', line 66

def update
  @tag = Tag.find(params[:id])

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