ruby on rails - My routes has resources :home, but rspec is saying routes not defined? -


my homecontroller has:

def about() end 

and have rspec test 'about' , fails saying there no route matches.

doesn't map actions in controller:

resources :home 

or have explicitly state each action in home controller?

resources :home sets default restful routes - index, show, new, create, edit, update, , destroy. additional routes have specified. looks you're adding simple collection route, you'd specify this:

resources :home   collection     'about'   end end 

this give route '/home/about'. assume rails 3. if you're in rails 2.x, so:

map.resources :home, :collection => {:about => :get} 

and command line, can see routes have available command:

rake routes 

i hope helps!

edit: if want default route, can add this:

match ':controller(/:action(/:id))' 

this default route match generic requests.

full article: routing in rails 3 own beast. there have been lot of questions lately, i've created detailed article code samples others:

routing in ruby on rails 3

i created companion rails 3 app can downloaded play around with, well:

https://github.com/kconrails/rails3_routing

if have questions, please hit site , ask. thanks!


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -