Class: BarcodesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/barcodes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /barcodes POST /barcodes.json



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

def create
  @barcode = Barcode.new(params[:barcode])

  respond_to do |format|
    if @barcode.save
      flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.barcode'))
      format.html { redirect_to(@barcode) }
      format.json { render :json => @barcode, :status => :created, :location => @barcode }
    else
      format.html { render :action => "new" }
      format.json { render :json => @barcode.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /barcodes/1 DELETE /barcodes/1.json



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

def destroy
  @barcode.destroy

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

#editObject

GET /barcodes/1/edit



44
45
# File 'app/controllers/barcodes_controller.rb', line 44

def edit
end

#indexObject

GET /barcodes GET /barcodes.json



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/barcodes_controller.rb', line 6

def index
  @barcodes = Barcode.page(params[:page])
  @start_rows = params[:start_rows]
  @start_cols = params[:start_cols]

  if params[:mode] == 'barcode'
    render :action => 'barcode', :layout => false
    return
  end

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

#newObject

GET /barcodes/new GET /barcodes/new.json



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

def new
  @barcode = Barcode.new

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

#showObject

GET /barcodes/1 GET /barcodes/1.json



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

def show
  respond_to do |format|
    format.html # show.html.erb
    format.json { render :json => @barcode }
    format.svg { send_data @barcode.data, :type => 'image/svg+json', :disposition => 'inline' }
  end
end

#updateObject

PUT /barcodes/1 PUT /barcodes/1.json



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

def update
  respond_to do |format|
    if @barcode.update_attributes(params[:barcode])
      flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.barcode'))
      format.html { redirect_to(@barcode) }
      format.json { head :no_content }
    else
      format.html { render :action => "edit" }
      format.json { render :json => @barcode.errors, :status => :unprocessable_entity }
    end
  end
end