开发者

Routing IN RUBY on RAILS

开发者 https://www.devze.com 2023-01-03 23:39 出处:网络
So for example, if I give like this map.root :controller => \"pages\", :action => \'show\', :slug => \"**homepage**\"

So for example, if I give like this

map.root :controller => "pages", :action => 'show', :slug => "**homepage**" 
map.connect '*slug', :controll开发者_运维问答er => 'pages', :action => 'show'

what will happen?


Have you run either rake routes or read the routing guides? Perhaps these will aid you.


From what I can deduce from your statement, map.root will just set the url root, "http://www.abc.com/", to automatically redirect to the "pages" controller and execute the "show" method and the slug is a human-readable id for that root.

From best I can tell, I am still a bit of a n00b in Rails, the connect statement will assign the pages controller and show action to all urls that end in "slug" within the root. For example, "http://www.abc.com/firstslug" would route to "/pages/show".

0

精彩评论

暂无评论...
验证码 换一张
取 消