开发者

Creating Twitter-style routes with Rails3

开发者 https://www.devze.com 2023-01-16 22:39 出处:网络
How can I make Twitter-style routes with Rails3? I\'ve tried the following: match \':username\', :controller => \"users\", :action => \"show\"

How can I make Twitter-style routes with Rails3?

I've tried the following:

match ':username', :controller => "users", :action => "show"
match ':username/:controller(/:action(/:id))', :path_prefix => '/:username'

EDIT

After some more digging through the docs, I did this and it seems to work:

scope '/:username' do
  resources :clubs
end

What is the "scope" method exactly and is there an automatic way of generating link_to开发者_StackOverflow URLs in my views?


The following matcher will match /dhh/update/1

match ':username/update/:id' => 'updates#show'

'update#show' is new in Rails 3 and is the short version of :controller => 'updates', :action => 'show'


Try clubs_path(:username => 'bob').

0

精彩评论

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