Class: TagsController

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

Overview

The tags controller.

Instance Method Summary (collapse)

Instance Method Details

- (Object) create

POST /Tags POST /Tags.json



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

def create
  @tag = Tag.new(tag_params)
  @tag.customer = current_customer

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

- (Object) destroy

DELETE /Tags/1 DELETE /Tags/1.json



97
98
99
100
101
102
103
104
105
# File 'app/controllers/tags_controller.rb', line 97

def destroy
  unless @tag.nil?
    @tag.destroy
    respond_to do |format|
      format.html { redirect_to tags_url }
      format.json { head :no_content }
    end
  end
end

- (Object) edit

GET /Tags/1/edit



59
60
# File 'app/controllers/tags_controller.rb', line 59

def edit
end

- (Object) index

GET /Tags GET /Tags.json



9
10
11
12
13
14
15
# File 'app/controllers/tags_controller.rb', line 9

def index
  if current_customer.role == 'admin'
    @tags = Tag.all
  else
    @tags = Tag.my(current_customer)
  end
end

- (Object) new

GET /Tags/new



51
52
53
54
55
56
# File 'app/controllers/tags_controller.rb', line 51

def new
  @tag = Tag.new
  if params[:mode] == 'in_mode'
    @tag.place_id = params['place_id']
  end
end

- (Object) show

GET /Tags/1 GET /Tags/1.json



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/tags_controller.rb', line 19

def show
  unless @tag.nil?
    @text_record = @tag.text_record

    unless @text_record.nil?
      @translations = @text_record.translations
    end

    @name_translations = @tag.name_translations

    if @tag.hardwares.count > 0
      @hardwares = @tag.hardwares

      # generate google map location
      @showMap = false
      
      @markers = []
      
      
      @tag.hardwares.with_location().each do | hardware |
        unless hardware.current_location.nil?
          @showMap = true

          @markers << { :lat => hardware.current_location.latitude, :lng => hardware.current_location.longitude}
        end
      end
      
    end
  end
end

- (Object) update

PATCH/PUT /Tags/1 PATCH/PUT /Tags/1.json



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

def update
  unless @tag.nil?
    respond_to do |format|
      if @tag.update(tag_params)
        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
end