Sha256: 18d784089a3ab5b6bacfb79a529e687442ba71aea921cf604735b4299d391a8c

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

require_dependency "help_popups/application_controller"

module HelpPopups
  class TopicsController < ApplicationController
    def index
      @topics = Topic.order(:title)
    end
  
    def new
      @topic = Topic.new
    end
  
    def create
      @topic = Topic.new(params[:topic])
      @topic.parent_id = -1
      
      if (@topic.save)
        redirect_to topics_path
      else
        render :new
      end
    end
  
    def edit
      @topic = Topic.find(params[:id])
    end
  
    def update
      @topic = Topic.find(params[:id])
      
      if (@topic.update_attributes(params[:topic]))
        redirect_to topics_path
      else
        render :edit
      end
    end
    
    def destroy
      @topic = Topic.find(params[:id])
      @topic.destroy
      redirect_to topics_path
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
help_popups-0.1.1 app/controllers/help_popups/topics_controller.rb
help_popups-0.1.0 app/controllers/help_popups/topics_controller.rb