add a short id redirector for comments
This commit is contained in:
parent
e9f005d83b
commit
18e027feb9
|
@ -66,6 +66,14 @@ class CommentsController < ApplicationController
|
|||
:content_type => "text/html", :locals => { :comment => comment }
|
||||
end
|
||||
|
||||
def redirect_from_short_id
|
||||
if comment = find_comment
|
||||
return redirect_to comment.url
|
||||
else
|
||||
return render :text => "can't find comment", :status => 400
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
if !((comment = find_comment) && comment.is_editable_by_user?(@user))
|
||||
return render :text => "can't find comment", :status => 400
|
||||
|
|
|
@ -84,6 +84,8 @@ Lobsters::Application.routes.draw do
|
|||
get "/s/:id/:title/comments/:comment_short_id" => "stories#show"
|
||||
get "/s/:id/(:title)" => "stories#show", :format => /html|json/
|
||||
|
||||
get "/c/:id" => "comments#redirect_from_short_id"
|
||||
|
||||
get "/u" => "users#tree"
|
||||
get "/u/:username" => "users#show", :as => "user"
|
||||
|
||||
|
|
Loading…
Reference in a new issue