rails 3:如何创建路径?

per*_*llo 9 routing routes ruby-on-rails

我需要一个关于如何在rails 3上创建新路径的解释.我想要这个链接

link_to "eat chocolate", eat_chocolate_user_path(user)
Run Code Online (Sandbox Code Playgroud)

等于

link_to "eat chocolate", :controller => 'user', :action=>'eat_chocolate', :id=> user
Run Code Online (Sandbox Code Playgroud)

我阅读了很多关于它的指南,包括railsguide的路由.但我仍然不知道它是如何工作的.

Kev*_*soi 10

将以下行添加到routes.rb文件中.

match 'user/eat_chocolate/:id' => 'user#eat_chocolate', :as => :eat_chocolate_user
Run Code Online (Sandbox Code Playgroud)

查找命名路线以获取更多信息.