Class: Admin::UrlRewritesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/admin/url_rewrites_controller.rb

Defined Under Namespace

Classes: Collection

Instance Method Summary collapse

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
34
# File 'app/controllers/admin/url_rewrites_controller.rb', line 26

def create
  @url_rewrite = UrlRewrite.new(url_rewrite_params)

  if @url_rewrite.save
    redirect_to admin_url_rewrite_path(@url_rewrite)
  else
    render :new, status: :unprocessable_entity, locals: { url_rewrite: @url_rewrite }
  end
end

#destroyObject



46
47
48
49
50
# File 'app/controllers/admin/url_rewrites_controller.rb', line 46

def destroy
  @url_rewrite.destroy!

  redirect_to admin_url_rewrites_path
end

#editObject



22
23
24
# File 'app/controllers/admin/url_rewrites_controller.rb', line 22

def edit
  render :edit, locals: { url_rewrite: @url_rewrite }
end

#indexObject



7
8
9
10
11
# File 'app/controllers/admin/url_rewrites_controller.rb', line 7

def index
  collection = Collection.new.with_params(params).apply(UrlRewrite.strict_loading)

  render locals: { collection: }
end

#newObject



17
18
19
20
# File 'app/controllers/admin/url_rewrites_controller.rb', line 17

def new
  @url_rewrite = UrlRewrite.new
  render :new, locals: { url_rewrite: @url_rewrite }
end

#showObject



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

def show
  render :show, locals: { url_rewrite: @url_rewrite }
end

#updateObject



36
37
38
39
40
41
42
43
44
# File 'app/controllers/admin/url_rewrites_controller.rb', line 36

def update
  @url_rewrite.attributes = url_rewrite_params

  if @url_rewrite.save
    redirect_to admin_url_rewrite_path(@url_rewrite)
  else
    render :edit, status: :unprocessable_entity, locals: { url_rewrite: @url_rewrite }
  end
end