Class: Admin::CustomTextsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/custom_texts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


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

def create
  @custom_text = CustomText.new(params[:custom_text])
  respond_to do |format|
    if @custom_text.save
      flash[:notice] = 'Custom text successfully created'
      format.html { redirect_to admin_custom_text_path(@custom_text) }
    else
      flash[:error] = 'Problems creating your new custom text'
      format.html { render action: :new }
    end
  end
end

#destroyObject


59
60
61
62
63
64
65
66
67
# File 'app/controllers/admin/custom_texts_controller.rb', line 59

def destroy
  custom_text = CustomText.find(params[:id])
  if custom_text.destroy
    flash[:notice] = 'Custom text deleted'
  else
    flash[:notice] = 'Failed to destroy custom text'
  end
  redirect_to admin_custom_texts_url
end

#editObject


41
42
43
44
45
46
# File 'app/controllers/admin/custom_texts_controller.rb', line 41

def edit
  @custom_text = CustomText.find(params[:id])
  respond_to do |format|
    format.html
  end
end

#indexObject


7
8
9
10
11
12
13
14
# File 'app/controllers/admin/custom_texts_controller.rb', line 7

def index
  @custom_texts = CustomText.all

  respond_to do |format|
    format.html
    format.xml { render xml: @custom_texts.to_xml }
  end
end

#newObject


24
25
26
# File 'app/controllers/admin/custom_texts_controller.rb', line 24

def new
  @custom_text = CustomText.new
end

#showObject


16
17
18
19
20
21
22
# File 'app/controllers/admin/custom_texts_controller.rb', line 16

def show
  @custom_text = CustomText.find(params[:id])
  respond_to do |format|
    format.html
    format.xml { render xml: @custom_text.to_xml }
  end
end

#updateObject


48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/admin/custom_texts_controller.rb', line 48

def update
  @custom_text = CustomText.find(params[:id])
  if @custom_text.update(params[:custom_text])
    flash[:notice] = 'Details have been updated'
    redirect_to admin_custom_text_path(@custom_text)
  else
    flash[:error] = 'Failed to update attributes'
    render action: 'edit', id: @custom_text.id
  end
end