【发布时间】:2020-02-20 23:32:17
【问题描述】:
嗨,我在 rails 路线中的前缀是不可见的。
这是我的文件 routes.rb
Rails.application.routes.draw do
get '/gossip/:id', to: 'gossip#show'
get '/welcome/:user_entry', to: 'welcome#personnal'
root 'home#show'
get '/team', to: 'team#show'
get '/contact', to: 'contact#show'
end
当我在终端运行 rails 路线时,我看到了:
Prefix Verb URI Pattern Controller#Action
GET /gossip/:id(.:format) gossip#show
GET /welcome/:user_entry(.:format) welcome#personnal
root GET / home#show
team GET /team(.:format) team#show
contact GET /contact(.:format) contact#show
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update
rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
如果我在id 之前删除:,我会看到前缀,但我的路线不再是动态的。有小费吗?谢谢
【问题讨论】:
-
你的前缀不可见是什么意思?哪条线与您的预期不同?你到底期待什么?
-
我需要前缀才能在
<%= link_to "click here", prefix_path %>中使用它? -
你只去
show和gossip吗?new、create等呢? -
目前我在数据库中只有八卦,我在一个页面中显示所有标题,我希望每个八卦的内容都有一个页面。
标签: ruby-on-rails ruby routes prefix invisible