Ruby on rails 如何设置本地化路由规范的区域设置?
我已根据设置了本地化路线 但是,在运行路由规范时,没有设置默认区域设置,从而导致错误,例如Ruby on rails 如何设置本地化路由规范的区域设置?,ruby-on-rails,rspec,localization,Ruby On Rails,Rspec,Localization,我已根据设置了本地化路线 但是,在运行路由规范时,没有设置默认区域设置,从而导致错误,例如 Failure/Error: it { expect(edit_user_path(1)).to eq("/users/1/edit") } ActionController::UrlGenerationError: No route matches {:action=>"edit", :controller=>"users", :id=>nil, :locale=>1} m
Failure/Error: it { expect(edit_user_path(1)).to eq("/users/1/edit") }
ActionController::UrlGenerationError:
No route matches {:action=>"edit", :controller=>"users", :id=>nil, :locale=>1} missing required keys: [:id]
在谷歌搜索了很多之后,我几乎没有找到测试本地化路由的最佳实践。有人能给我指点好文章吗
具体来说,我想知道:
['en','fr'].each do |locale|
expect(edit_user_path(1, locale: locale)).to eq("/#{locale}/users/1/edit")
end
['en','fr'].each do |locale|
expect(edit_user_path(1, locale: locale)).to eq("/#{locale}/users/1/edit")
end