Skip to content
Browse files

refactored topics controller

  • Loading branch information...
1 parent f4c332f commit fb89d19ac967f3b034680395c1fe09068a4e6f05 Matt Hodgson committed
Showing with 9 additions and 3 deletions.
  1. +9 −3 app/controllers/topics_controller.rb
View
12 app/controllers/topics_controller.rb
@@ -1,5 +1,6 @@
class TopicsController < ApplicationController
before_filter :require_user
+ before_filter :find_topic, :only => [:show, :edit, :update]
def new
@topic = Topic.new
@@ -10,15 +11,14 @@ def create
end
def show
- @topic = Topic.find(params[:id])
+
end
def edit
- @topic = Topic.find(params[:id])
+
end
def update
- @topic = Topic.find(params[:id])
if @topic.update_attributes(params[:topic])
flash[:notice] = "Topic updated!"
redirect_to topics_url
@@ -26,5 +26,11 @@ def update
render :action => :edit
end
end
+
+ protected
+
+ def find_topic
+ @topic = Topic.find(params[:id])
+ end
end

0 comments on commit fb89d19

Please sign in to comment.
Something went wrong with that request. Please try again.