Class: Helpdesk::FaqsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/helpdesk/faqs_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#ensure_user, #helpdesk_admin?

Instance Method Details

#createObject

POST /faqs POST /faqs.json



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/helpdesk/faqs_controller.rb', line 43

def create
  @faq = Faq.new(params[:faq])
  
  respond_to do |format|
    if @faq.save
      format.html { redirect_to @faq, notice: 'Faq was successfully created.' }
      format.json { render json: @faq, status: :created, location: @faq }
    else
      format.html { render action: "new" }
      format.json { render json: @faq.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /faqs/1 DELETE /faqs/1.json



75
76
77
78
79
80
81
82
83
# File 'app/controllers/helpdesk/faqs_controller.rb', line 75

def destroy
  @faq = Faq.find(params[:id])
  @faq.destroy
  
  respond_to do |format|
    format.html { redirect_to faqs_url }
    format.json { head :no_content }
  end
end

#editObject

GET /faqs/1/edit



37
38
39
# File 'app/controllers/helpdesk/faqs_controller.rb', line 37

def edit
  @faq = Faq.find(params[:id])
end

#indexObject

GET /faqs GET /faqs.json



5
6
7
8
9
10
11
12
# File 'app/controllers/helpdesk/faqs_controller.rb', line 5

def index
  @faqs = Faq.all
  
  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @faqs }
  end
end

#newObject

GET /faqs/new GET /faqs/new.json



27
28
29
30
31
32
33
34
# File 'app/controllers/helpdesk/faqs_controller.rb', line 27

def new
  @faq = Faq.new
  
  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @faq }
  end
end

#showObject

GET /faqs/1 GET /faqs/1.json



16
17
18
19
20
21
22
23
# File 'app/controllers/helpdesk/faqs_controller.rb', line 16

def show
  @faq = Faq.find(params[:id])
  
  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @faq }
  end
end

#updateObject

PUT /faqs/1 PUT /faqs/1.json



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/controllers/helpdesk/faqs_controller.rb', line 59

def update
  @faq = Faq.find(params[:id])
  
  respond_to do |format|
    if @faq.update_attributes(params[:faq])
      format.html { redirect_to @faq, notice: 'Faq was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @faq.errors, status: :unprocessable_entity }
    end
  end
end