Skip to content

Commit

Permalink
Clean up commenting routes, the hack that was there was for a much
Browse files Browse the repository at this point in the history
earlier version of Rails and is no longer required.
  • Loading branch information
xaviershay committed Jul 23, 2011
1 parent 329e4c0 commit 71655a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
6 changes: 1 addition & 5 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ class CommentsController < ApplicationController
before_filter :find_post, :except => [:new]

def index
if request.post? || using_open_id?
create
else
redirect_to(post_path(@post))
end
redirect_to(post_path(@post))
end

def new
Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
resources :pages, :only => [:show]

constraints :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ do
post ':year/:month/:day/:slug/comments' => 'comments#index'
get ':year/:month/:day/:slug/comments' => 'comments#index'
post ':year/:month/:day/:slug/comments' => 'comments#create'
get ':year/:month/:day/:slug/comments/new' => 'comments#new'
get ':year/:month/:day/:slug' => 'posts#show'
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/comments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def mock_post!
before(:each) do
mock_post!

post :index, :year => '2007', :month => '01', :day => '01', :slug => 'a-post', :comment => {
post :create, :year => '2007', :month => '01', :day => '01', :slug => 'a-post', :comment => {
:author => 'Don Alias',
:body => 'This is a comment',

Expand Down

0 comments on commit 71655a5

Please sign in to comment.