Tag: 路线

如何获取我的rails应用程序中的所有路由?

我可以在rails应用程序中获取所有路由吗? 我需要一个像rake routes的输出,并将结果放在一个数组中。 可能吗? 怎么样?

获取Rails URL帮助程序以自动输出https URL

我正在开发一个混合了http和https的网站 – 最简单/最简单的方法是让链接使用正确的路由协议 – 是否可以在路由文件中指定? 假设我在Rails 3中有以下路由。 匹配“/ test”=>“test #index”,:as =>:test,:constraints => {:protocol =>’https’} 如果我在http页面上,并且我使用test_url() ,它将输出http://domain.com/test 。 我想改为https://domain.com/test 。 我知道我可以使用test_url(:secure => true) ,但这是重复的逻辑。 我知道我可以http://domain.com/test到https://domain.com/test ,但这是一个额外的重定向,加上它在表单post上失败了。 想法?

rails路由中的资源和资源之间的差异?

rails路由中resource和resources之间的区别是什么 resource :geocoder 和 resources :posts 它们之间有什么区别?

ruby脚本中“rake routes”的结果

rake routes很慢(我的电脑30秒)但我需要它来路由规格。 那么,有没有办法让所有路线像耙路线? (或rake路线如何工作?) 我使用Rails 3,我所看到的只是Rails 3,我发现我无法在rails doc中使用。

Ruby on Rails。 Unicode路由

是否可以在Rails中将Unicode字符串设置为路径段? 我尝试以下方法: # app/controllers/magazines_controller.rb class MagazinesController < ApplicationController def index end end # encoding: utf-8 # config/routes.rb PublishingHouse::Application.routes.draw do resources :magazines, :only => :index, :path => :журналы # a Unicode string is set as a segment of the path end # encoding: utf-8 # config/routes.rb PublishingHouse::Application.routes.draw do resources :magazines, :only => :index, :path => :журналы […]

Rails路线:资源错误单数

我在routes.rb有以下行(Rails 4.1.4): resources :request_caches 但是,当我运行rake routes我得到以下输出: request_caches GET /request_caches(.:format) request_caches#index POST /request_caches(.:format) request_caches#create new_request_cach GET /request_caches/new(.:format) request_caches#new edit_request_cach GET /request_caches/:id/edit(.:format) request_caches#edit request_cach GET /request_caches/:id(.:format) request_caches#show PATCH /request_caches/:id(.:format) request_caches#update PUT /request_caches/:id(.:format) request_caches#update DELETE /request_caches/:id(.:format) request_caches#destroy 如您所见,Rails以某种方式将request_caches复数映射到request_cach单数。 但它应该是request_cache 。 这是一种特殊情况,因为caches这个词? 我也玩过 resources :request_caches, as: :request_cache 但这导致了错误的路由,如request_cache_index 。 此外,我认为这是一项标准任务,应该使用Rails实习生路线助手清楚地解决。 那么,我做错了什么?