rails 3 : How to create a path?
I need an explanation about how create new path on rails 3. I want this link for example
link_to "eat chocolate", eat_chocolate_user_path(user)
be equals to
link_to "eat chocolate", :controller => 'user', :action=>'eat_chocolate', :id=> user
I read many guides about it, including routing of railsguide. But i still do not know ho开发者_开发技巧w it exactly work.
add the following line to your routes.rb file.
match 'user/eat_chocolate/:id' => 'user#eat_chocolate', :as => :eat_chocolate_user
Look up named routes for more info.
In some cases it will be better to use GET.
Using match will accept ALL http verbs GET PUT POST DELETE meaning that somebody could potentially mis-use your application.  If all you're doing is showing something in a #show action, you should use this instead
get 'user/eat_chocolate/:id' => 'user#eat_chocolate', :as => :eat_chocolate_user
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论