Permalink
Browse files

Find a post by its url not id

  • Loading branch information...
1 parent e64a0b6 commit ac4055de58e6acd50f78172145b83c6cc30e2cd3 @jdpace committed Oct 20, 2009
@@ -5,7 +5,7 @@ def index
end
def show
- @post = Post.find(params[:id])
+ @post = Post.find_by_url!(params[:id])
end
end
@@ -1,3 +1,3 @@
- @posts.each do |post|
- %h3= post.title
+ %h3= link_to post.title, post_path(post)
.html= post.body_html
@@ -17,7 +17,7 @@ class PostsControllerTest < ActionController::TestCase
context "Get /posts/:id" do
setup do
@post = Factory.build(:post, :url => 'post', :created_at => 1.day.ago)
- Post.stubs(:find).with(@post.to_param).returns(@post)
+ Post.stubs(:find_by_url!).with(@post.to_param).returns(@post)
get :show, :id => @post.to_param
end

0 comments on commit ac4055d

Please sign in to comment.