2008-06-26

rails route

关键字: url_for与路由
      # ==== Relying on named routes
      #
      # If you instead of a hash pass a record (like an Active Record or Active Resource) as the options parameter,
      # you'll trigger the named route for that record. The lookup will happen on the name of the class. So passing
      # a Workshop object will attempt to use the workshop_path route. If you have a nested route, such as 
      # admin_workshop_path you'll have to call that explicitly (it's impossible for url_for to guess that route). 
      #

有这样一个路由:
map.show_forums_topic '/forums/:forum_id/topics/:topic_id/', :controller=>'topic', :action=>'show'
我们就可以用来映射到些地址:
redirect_to show_forums_topic(@forums,@topic)
或者编辑:redirect_to edit_forums_topic(@forums,@topic)
评论
发表评论

您还没有登录,请登录后发表评论

xu_wccq
搜索本博客
我的相册
Ac7ad940-edbc-3b23-8443-5fe2ea338061-thumb
productcenter.bmp
共 2 张
最近加入圈子
存档
最新评论