@@ -9,7 +9,7 @@ class ArticlesController < ApplicationController
99 include WatchersHelper
1010
1111 before_filter :find_project_by_project_id , :authorize
12- before_filter :get_article , :only => [ :add_attachment , :show , :edit , :update , :add_comment , :destroy , :destroy_comment , :diff , :revert , :version ]
12+ before_filter :get_article , :except => [ :index , :new , :create , :preview , :comment , :tagged , :rate ]
1313
1414 rescue_from ActionView ::MissingTemplate , :with => :force_404
1515 rescue_from ActiveRecord ::RecordNotFound , :with => :force_404
@@ -53,7 +53,7 @@ def create
5353 @article = KbArticle . new ( params [ :article ] )
5454 @article . category_id = params [ :category_id ]
5555 @article . author_id = User . current . id
56- @article . project_id = KbCategory . find ( params [ :category_id ] ) . project_id
56+ @article . project_id = KbCategory . find ( params [ :category_id ] ) . project_id
5757 @categories = @project . categories . find ( :all )
5858 # don't keep previous comment
5959 @article . version_comments = params [ :article ] [ :version_comments ]
@@ -116,14 +116,14 @@ def add_comment
116116 show
117117 render :action => 'show'
118118 end
119- end
119+ end
120120 end
121121
122122 def destroy_comment
123123 @article . without_locking do
124124 @article . comments . find ( params [ :comment_id ] ) . destroy
125125 redirect_to :action => 'show' , :id => @article , :project_id => @project
126- end
126+ end
127127 end
128128
129129 def destroy
@@ -140,13 +140,10 @@ def add_attachment
140140
141141 def tagged
142142 @tag = params [ :id ]
143- my_direction = params [ :direction ]
144- my_sort = params [ :sort ]
145- if my_sort && my_direction
146- my_order = "#{ my_sort } #{ my_direction } "
147- @list = @project . articles . order ( my_order ) . tagged_with ( @tag )
143+ @list = if params [ :sort ] && params [ :direction ]
144+ @project . articles . order ( "#{ params [ :sort ] } #{ params [ :direction ] } " ) . tagged_with ( @tag )
148145 else
149- @list = @ project. articles . tagged_with ( @tag )
146+ @project . articles . tagged_with ( @tag )
150147 end
151148 end
152149
0 commit comments