Class: Admin::RedirectsController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/redirects_controller.rb

Instance Method Summary collapse

Methods included from BlogHelper

#blog_base_url, #this_blog

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/admin/redirects_controller.rb', line 17

def create
  @redirect = this_blog.redirects.build(redirect_params)

  if @redirect.save
    flash[:notice] = I18n.t("admin.base.successfully_created",
                            name: Redirect.model_name.human)
    redirect_to admin_redirects_url
  else
    render :index
  end
end

#destroyObject



39
40
41
42
# File 'app/controllers/admin/redirects_controller.rb', line 39

def destroy
  @redirect.destroy
  redirect_to admin_redirects_url, notice: I18n.t("admin.redirects.destroy.success")
end

#editObject



12
13
14
15
# File 'app/controllers/admin/redirects_controller.rb', line 12

def edit
  @redirects = Redirect.where(content_id: nil).order("id desc").page(params[:page])
    .per(this_blog.admin_display_elements)
end

#indexObject



6
7
8
9
10
# File 'app/controllers/admin/redirects_controller.rb', line 6

def index
  @redirects = Redirect.where(content_id: nil).order("id desc").page(params[:page])
    .per(this_blog.admin_display_elements)
  @redirect = Redirect.new
end

#updateObject



29
30
31
32
33
34
35
36
37
# File 'app/controllers/admin/redirects_controller.rb', line 29

def update
  if @redirect.update(redirect_params)
    flash[:notice] = I18n.t("admin.base.successfully_updated",
                            name: Redirect.model_name.human)
    redirect_to admin_redirects_url
  else
    render :edit
  end
end