Class: Cmtool::ContactFormsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/cmtool/contact_forms_controller.rb

Instance Method Summary collapse

Methods included from ControllerGlue

#cmtool_user

Instance Method Details

#addObject



87
88
89
90
91
92
93
94
# File 'app/controllers/cmtool/contact_forms_controller.rb', line 87

def add
  @contact_form = Cmtool::ContactForm.new(contact_form_params)
  if @contact_form.save
    redirect_to :back, notice: I18n.t('cmtool.contact_form.submitted')
  else
    redirect_to :back, alert: I18n.t('cmtool.contact_form.submission_failed', reason: @contact_form.errors.full_messages.to_sentence )
  end
end

#createObject

POST /contact_forms POST /contact_forms.xml



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/cmtool/contact_forms_controller.rb', line 45

def create
  @contact_form = Cmtool::ContactForm.new(contact_form_params)

  respond_to do |format|
    if @contact_form.save
      format.html { redirect_to([cmtool, @contact_form], :notice => I18n.t('cmtool.action.create.successful', :model => Cmtool::ContactForm.model_name.human)) }
      format.xml  { render :xml => @contact_form, :status => :created, :location => @contact_form }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @contact_form.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /contact_forms/1 DELETE /contact_forms/1.xml



77
78
79
80
81
82
83
84
85
# File 'app/controllers/cmtool/contact_forms_controller.rb', line 77

def destroy
  @contact_form = Cmtool::ContactForm.find(params[:id])
  @contact_form.destroy

  respond_to do |format|
    format.html { redirect_to(cmtool.contact_forms_url) }
    format.xml  { head :ok }
  end
end

#editObject

GET /contact_forms/1/edit



39
40
41
# File 'app/controllers/cmtool/contact_forms_controller.rb', line 39

def edit
  @contact_form = Cmtool::ContactForm.find(params[:id])
end

#indexObject

GET /contact_forms GET /contact_forms.xml



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

def index
  @contact_forms = Cmtool::ContactForm.all

  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render :xml => @contact_forms }
  end
end

#newObject

GET /contact_forms/new GET /contact_forms/new.xml



29
30
31
32
33
34
35
36
# File 'app/controllers/cmtool/contact_forms_controller.rb', line 29

def new
  @contact_form = Cmtool::ContactForm.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @contact_form }
  end
end

#showObject

GET /contact_forms/1 GET /contact_forms/1.xml



18
19
20
21
22
23
24
25
# File 'app/controllers/cmtool/contact_forms_controller.rb', line 18

def show
  @contact_form = Cmtool::ContactForm.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.xml  { render :xml => @contact_form }
  end
end

#updateObject

PUT /contact_forms/1 PUT /contact_forms/1.xml



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/cmtool/contact_forms_controller.rb', line 61

def update
  @contact_form = Cmtool::ContactForm.find(params[:id])

  respond_to do |format|
    if @contact_form.update_attributes(contact_form_params)
      format.html { redirect_to([cmtool, @contact_form], :notice => I18n.t('cmtool.action.update.successful', :model => Cmtool::ContactForm.model_name.human)) }
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @contact_form.errors, :status => :unprocessable_entity }
    end
  end
end