开发者

Whats the meaning of :slug in route.rb (ruby on rails). How its mapped?

Whats the meaning of :slug in routes.rb (开发者_Python百科ruby on rails). How its mapped?


As with any other name, :param syntax means that this part of the url corresponds to a parameter named param.

So, taking an example of how SO urls are defined, we can observe the following route:

map.connect "/questions/:id/:slug", :controller => "questions", :action => "show"

And when you come to an url of the form http://stackoverflow.com/questions/3082982/whats-the-meaning-of-slug-in-route-rb-ruby-on-rails-how-its-mapped, it will be handled by QuestionsController#show with the params hash { :id => "3082982", :slug => "whats-the-meaning-of-slug-in-route-rb-ruby-on-rails-how-its-mapped" }.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜