Class: ItemHasUseRestrictionsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /item_has_use_restrictions POST /item_has_use_restrictions.json



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

def create
  @item_has_use_restriction = ItemHasUseRestriction.new(item_has_use_restriction_params)

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

#destroyObject

DELETE /item_has_use_restrictions/1 DELETE /item_has_use_restrictions/1.json



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

def destroy
  @item_has_use_restriction.destroy

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

#editObject

GET /item_has_use_restrictions/1/edit



41
42
43
# File 'app/controllers/item_has_use_restrictions_controller.rb', line 41

def edit
  @use_restrictions = UseRestriction.all
end

#indexObject

GET /item_has_use_restrictions GET /item_has_use_restrictions.json



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

def index
  if @item
    @item_has_use_restrictions = @item.item_has_use_restrictions.order('item_has_use_restrictions.id DESC').page(params[:page])
  else
    @item_has_use_restrictions = ItemHasUseRestriction.order('id DESC').page(params[:page])
  end

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

#newObject

GET /item_has_use_restrictions/new GET /item_has_use_restrictions/new.json



31
32
33
34
35
36
37
38
# File 'app/controllers/item_has_use_restrictions_controller.rb', line 31

def new
  @use_restrictions = UseRestriction.all

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

#showObject

GET /item_has_use_restrictions/1 GET /item_has_use_restrictions/1.json



22
23
24
25
26
27
# File 'app/controllers/item_has_use_restrictions_controller.rb', line 22

def show
  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @item_has_use_restriction }
  end
end

#updateObject

PUT /item_has_use_restrictions/1 PUT /item_has_use_restrictions/1.json



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

def update
  @item_has_use_restriction.assign_attributes(item_has_use_restriction_params)
  respond_to do |format|
    if @item_has_use_restriction.save
      format.html { redirect_to @item_has_use_restriction, notice: t('controller.successfully_updated', model: t('activerecord.models.item_has_use_restriction')) }
      format.json { head :no_content }
    else
      @use_restrictions = UseRestriction.all
      format.html { render action: "edit" }
      format.json { render json: @item_has_use_restriction.errors, status: :unprocessable_entity }
    end
  end
end