Class: HelpPopups::TopicsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/help_popups/topics_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#hi

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/help_popups/topics_controller.rb', line 25

def create
  @topic = Topic.new(params[:topic])
  @topic.parent_id = -1
  
  if (@topic.save)
    redirect_to topics_path
  else
    render :new
  end
end

#destroyObject



50
51
52
53
54
# File 'app/controllers/help_popups/topics_controller.rb', line 50

def destroy
  @topic = Topic.find(params[:id])
  @topic.destroy
  redirect_to topics_path
end

#editObject



36
37
38
# File 'app/controllers/help_popups/topics_controller.rb', line 36

def edit
  @topic = Topic.find(params[:id])
end

#indexObject



17
18
19
# File 'app/controllers/help_popups/topics_controller.rb', line 17

def index
  @topics = Topic.order(:title)
end

#loginObject



5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/help_popups/topics_controller.rb', line 5

def 
  if !(params[:help_popups_password].nil?)
    if (params[:help_popups_password] == Rails.configuration.help_popups_password)
      session[:help_popups_clearance] = 1
    else
      flash[:error] = "Invalid Password!"
    end
  end
  
  redirect_to topics_path
end

#newObject



21
22
23
# File 'app/controllers/help_popups/topics_controller.rb', line 21

def new
  @topic = Topic.new
end

#updateObject



40
41
42
43
44
45
46
47
48
# File 'app/controllers/help_popups/topics_controller.rb', line 40

def update
  @topic = Topic.find(params[:id])
  
  if (@topic.update_attributes(params[:topic]))
    redirect_to topics_path
  else
    render :edit
  end
end