ruby on rails - The delete http request for microposts in Figure 13.54 of Michael Hartl's tutorial has no route matches? -


from following excerpt of section:

test "should redirect destroy wrong micropost"   log_in_as(users(:michael))   micropost = microposts(:ants)   assert_no_difference 'micropost.count'     delete micropost_path(micropost)   end   assert_redirected_to root_url end 

the following line

delete micropost_path(micropost) 

was giving me following error:

actioncontroller::urlgenerationerror: no route matches  {:action=>"/microposts/583546149", :controller=>"microposts"} 

comparing action: portion snippets had seen online of typical delete http requests clued me in inherently wrong. had curiously noted, too, in tutorial michael hartl used following syntax deleting resources:

delete :destroy, id: micropost 

just clear, latter seems work expected. question, then, twofold:

are both supposed valid? what's difference?

that test make sure micropost(:ants) cannot created because method micropost(:oranges). why gave error , redirected, supposed do. test passed.

test syntax may differ.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -