Skip to content
Browse files

dry'ed forums controller a bit

  • Loading branch information...
1 parent f7d223d commit 8d4dbd88336f0db015f18e9997163e80cedcb99c @dimko dimko committed
Showing with 8 additions and 4 deletions.
  1. +8 −4 app/controllers/forums_controller.rb
View
12 app/controllers/forums_controller.rb
@@ -1,5 +1,6 @@
class ForumsController < ApplicationController
before_filter :admin_required, :except => [:index, :show]
+ before_filter :find_forum, :only => [:show, :edit, :update, :destroy]
# GET /forums
# GET /forums.xml
@@ -18,7 +19,6 @@ def index
# GET /forums/1
# GET /forums/1.xml
def show
- @forum = current_site.forums.find_by_permalink!(params[:id])
(session[:forums] ||= {})[@forum.id] = Time.now.utc
(session[:forums_page] ||= Hash.new(1))[@forum.id] = current_page if current_page > 1
@@ -43,7 +43,6 @@ def new
# GET /forums/1/edit
def edit
- @forum = current_site.forums.find_by_permalink!(params[:id])
end
# POST /forums
@@ -66,7 +65,6 @@ def create
# PUT /forums/1
# PUT /forums/1.xml
def update
- @forum = current_site.forums.find_by_permalink(params[:id])
respond_to do |format|
if @forum.update_attributes(params[:forum])
@@ -83,7 +81,6 @@ def update
# DELETE /forums/1
# DELETE /forums/1.xml
def destroy
- @forum = current_site.forums.find_by_permalink(params[:id])
@forum.destroy
respond_to do |format|
@@ -91,4 +88,11 @@ def destroy
format.xml { head :ok }
end
end
+
+ protected
+
+ def find_forum
+ @forum = current_site.forums.find_by_permalink!(params[:id])
+ end
+
end

0 comments on commit 8d4dbd8

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