ruby Ruby on Rails:常见路由
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby Ruby on Rails:常见路由相关的知识,希望对你有一定的参考价值。
# Manually setting route
get '/users/:id', to: 'users#show'
get '/users', to: 'users#index', as: 'all_users'
# <%= link_to "All users", all_users_path %>
# Redirect routes
get '/all', to: redirect('/tweets')
get '/all/:id', to: redirect('/tweets/%{id}')
# Set root route
root to: 'users#index'
# Sets standardized routes
resources :users
# Restrict routes
resources :users, only: [:index, :create]
# Restrict routes through exceptions
resources :users, except: :new
以上是关于ruby Ruby on Rails:常见路由的主要内容,如果未能解决你的问题,请参考以下文章
Ruby on Rails 路由解析
Ruby on Rails 路由到控制器
Ruby on Rails:延迟的作业无法使用邮件程序并给出路由错误
如何在 Ruby on Rails 中创建一个包罗万象的路由?
Ruby on Rails 将通配符子域路由到控制器/操作
ruby on rails中收集路线和会员路线的区别?