Class: Backend::SnippetsController

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

Instance Method Summary collapse

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



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

def create
  @model = Snippet.new allowed_params

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

#indexObject



7
8
9
# File 'app/controllers/backend/snippets_controller.rb', line 7

def index
  @snippets = Snippet.order(:description)
end

#newObject



11
12
13
# File 'app/controllers/backend/snippets_controller.rb', line 11

def new
  @model = Snippet.new
end

#updateObject



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

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