在我的 Rails 项目中,在我index
看来,我有一个链接
<%= link_to 'Show all posts', show_all_path %>
在routes.rb
中,我有一条路线:
match "show_all" => "Posts#show_all"
当我单击该链接时,它来自
http://<domain name>/my_rails_project
到
http://<domain name>/my_rails_project//show_all
有用。但是,有两个正斜杠看起来不是很好。我可以让它只出现一个正斜杠吗?
编辑:这些是我的一些文件:
配置/环境.rb
require File.expand_path('../application', __FILE__)
Blog::Application.initialize!
配置/环境/development.rb
Blog::Application.configure do
config.cache_classes = false
config.whiny_nils = true
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.action_dispatch.best_standards_support = :builtin
config.action_controller.asset_host = "//pauls.scripts.asu.edu/blog/public"
end
配置/路由.rb:
Blog::Application.routes.draw
do resources :posts match "show_all" => "Posts#show_all"
end
的输出rake routes
show_all /show_all(.:format) {:action=>"show_all", :controller=>"Posts"}