Class: TextRecordsController

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

Overview

The text records controller.

Instance Method Summary (collapse)

Instance Method Details

- (Object) create

POST /text_records POST /text_records.json



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/text_records_controller.rb', line 34

def create
  @text_record = TextRecord.new(text_record_params)

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

- (Object) destroy

DELETE /text_records/1 DELETE /text_records/1.json



66
67
68
69
70
71
72
# File 'app/controllers/text_records_controller.rb', line 66

def destroy
  @text_record.destroy
  respond_to do |format|
    format.html { redirect_to text_records_url }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /text_records/1/edit



28
29
30
# File 'app/controllers/text_records_controller.rb', line 28

def edit
  @tag_id = params['tag_id']
end

- (Object) index

GET /text_records GET /text_records.json



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

def index
  if current_customer.role == 'admin'
    @text_records = TextRecord.all
  else
    @text_records = TextRecord.joins(:tag).where('Tags.customer_id' => current_customer)
  end
end

- (Object) new

GET /text_records/new



23
24
25
# File 'app/controllers/text_records_controller.rb', line 23

def new
  @text_record = TextRecord.new
end

- (Object) show

GET /text_records/1 GET /text_records/1.json



19
20
# File 'app/controllers/text_records_controller.rb', line 19

def show
end

- (Object) update

PATCH/PUT /text_records/1 PATCH/PUT /text_records/1.json



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

def update
  tag_id = params['text_record']['tag_id']

  respond_to do |format|
    if @text_record.update(text_record_params)
      format.html { redirect_to tag_path(tag_id), notice: 'Text record was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: 'edit' }
      format.json { render json: @text_record.errors, status: :unprocessable_entity }
    end
  end
end