【发布时间】:2010-09-14 14:39:40
【问题描述】:
我使用的是 Rails 3.0,并且我的 routes.rb 文件中有以下内容:
scope "/:location" do
resources :agents
end
所以我可以这样做:
agents = Agent.where("location = ?", params[:location])
(可能有更好的方法来做到这一点..?主要是我想要这样的 URL:myurl.com/london/agents)
无论如何,我的问题在于测试(我仍在学习),我怎样才能使它与范围一起工作:
class AgentsControllerTest < ActionController::TestCase
test "should get index" do
get 'index'
assert_response :success
end
end
它只是得到一个找不到路由的错误。
任何帮助都会很棒,谢谢。
【问题讨论】:
标签: ruby-on-rails testing routes