Class: FlyAdmin::CategoriesController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_admin!

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
# File 'app/controllers/fly_admin/categories_controller.rb', line 11

def create
  if @category.save
    flash[:notice] = "Сериал успешно создан "
    redirect_to categories_path
  else
    render 'new'
  end
end

#destroyObject



37
38
39
40
41
42
# File 'app/controllers/fly_admin/categories_controller.rb', line 37

def destroy
  @category = Category.find(params[:id])
  @category.destroy!
  flash[:notice] = "Сериал успешно удален"
  redirect_to categories_path  
end

#editObject



24
25
26
# File 'app/controllers/fly_admin/categories_controller.rb', line 24

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

#indexObject



7
8
9
# File 'app/controllers/fly_admin/categories_controller.rb', line 7

def index
  @categories = Category.all
end

#newObject



20
21
22
# File 'app/controllers/fly_admin/categories_controller.rb', line 20

def new
  @category = Category.new
end

#seasonsObject



44
45
46
47
# File 'app/controllers/fly_admin/categories_controller.rb', line 44

def seasons
  @category = Category.find(params[:category_id])
  @seasons = @category.seasons.each {|s| s.json_title = JSON.parse(s.title)["ru"]}
end

#updateObject



28
29
30
31
32
33
34
35
# File 'app/controllers/fly_admin/categories_controller.rb', line 28

def update
  if @category.update_attributes(category_params)
    flash[:notice] = "Сериал обновлен"
    redirect_to categories_path
  else
    render action: "edit"
  end
end