Class: EventCategoriesController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /event_categories POST /event_categories.json



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/event_categories_controller.rb', line 42

def create
  @event_category = EventCategory.new(event_category_params)

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

#destroyObject

DELETE /event_categories/1 DELETE /event_categories/1.json



77
78
79
80
81
82
83
84
# File 'app/controllers/event_categories_controller.rb', line 77

def destroy
  @event_category.destroy

  respond_to do |format|
    format.html { redirect_to event_categories_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.event_category')) }
    format.json { head :no_content }
  end
end

#editObject

GET /event_categories/1/edit



37
38
# File 'app/controllers/event_categories_controller.rb', line 37

def edit
end

#indexObject

GET /event_categories GET /event_categories.json



7
8
9
10
11
12
13
14
# File 'app/controllers/event_categories_controller.rb', line 7

def index
  @event_categories = EventCategory.order(:position)

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

#newObject

GET /event_categories/new GET /event_categories/new.json



27
28
29
30
31
32
33
34
# File 'app/controllers/event_categories_controller.rb', line 27

def new
  @event_category = EventCategory.new

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

#showObject

GET /event_categories/1 GET /event_categories/1.json



18
19
20
21
22
23
# File 'app/controllers/event_categories_controller.rb', line 18

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

#updateObject

PUT /event_categories/1 PUT /event_categories/1.json



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/event_categories_controller.rb', line 58

def update
  if params[:move]
    move_position(@event_category, params[:move])
    return
  end

  respond_to do |format|
    if @event_category.update(event_category_params)
      format.html { redirect_to @event_category, notice:  t('controller.successfully_updated', model:  t('activerecord.models.event_category')) }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @event_category.errors, status: :unprocessable_entity }
    end
  end
end