Class: Backend::ArticlesController

Inherits:
BaseController
  • Object
show all
Includes:
Concerns::Backend::TranslatableController, Concerns::PaginationController
Defined in:
app/controllers/backend/articles_controller.rb

Instance Method Summary collapse

Methods included from Concerns::PaginationController

#page_number, #paginate, #per_page

Methods included from Concerns::Backend::TranslatableController

#update_translation

Methods inherited from BaseController

#breadcrumb, #current_admin, #default_app_locale, #translate_notice

Methods included from Udongo::Cryptography

#crypt

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/backend/articles_controller.rb', line 16

def create
  @model = Article.new(allowed_params)

  if @model.save
    redirect_to edit_translation_backend_article_path(@model, translation_locale: default_app_locale),
                notice: translate_notice(:added, :article)
  else
    render :new
  end
end

#destroyObject



35
36
37
38
# File 'app/controllers/backend/articles_controller.rb', line 35

def destroy
  @model.destroy
  redirect_to backend_articles_path, notice: translate_notice(:deleted, :article)
end

#indexObject



8
9
10
# File 'app/controllers/backend/articles_controller.rb', line 8

def index
  @articles = paginate Article.order('published_at DESC')
end

#newObject



12
13
14
# File 'app/controllers/backend/articles_controller.rb', line 12

def new
  @model = Article.new
end

#updateObject



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

def update
  if @model.update_attributes allowed_params
    redirect_to backend_articles_path, notice: translate_notice(:edited, :article)
  else
    render :edit
  end
end