Permalink
Browse files

refactored topics controller

  • Loading branch information...
Matt Hodgson
Matt Hodgson committed May 21, 2009
1 parent f4c332f commit fb89d19ac967f3b034680395c1fe09068a4e6f05
Showing with 9 additions and 3 deletions.
  1. +9 −3 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,21 +11,26 @@ 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
else
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.