Class: TmLyn::CategoriesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @cat = Category.new(cat_params)
  if @cat.save
    redirect_to categories_path, notice:"Category created"
  else
    render :new, status: :unprocessable_entity
  end
end

#editObject



17
18
19
# File 'app/controllers/tm_lyn/categories_controller.rb', line 17

def edit
  @cat = Category.find(params[:id])
end

#indexObject



3
4
5
# File 'app/controllers/tm_lyn/categories_controller.rb', line 3

def index
  @cats = Category.all
end

#newObject



6
7
8
# File 'app/controllers/tm_lyn/categories_controller.rb', line 6

def new
  @cat = Category.new
end

#updateObject



20
21
22
23
24
25
26
27
# File 'app/controllers/tm_lyn/categories_controller.rb', line 20

def update
  @cat = Category.find(params[:id])
  if @cat.update(cat_params)
    redirect_to categories_path, notice:"Category updated successfully"
  else
    render :edit
  end
end