【发布时间】:2011-06-25 19:26:04
【问题描述】:
我一直在遇到此错误以获取 GET 请求以显示操作。
1) ShopController GET 'show' should be successful
Failure/Error: get 'show', :id=>@shop.user.nickname
ActionController::RoutingError:
No route matches {:id=>"picardo", :controller=>"shop", :action=>"show"}
# ./spec/controllers/shop_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
我的路线是这样的。
#routes.rb
resources :shop, :only=>[:show]
这是控制器规格:
#shop_controller_spec.rb
before(:each) do
@shop = Fabricate(:shop)
end
describe "GET 'show'" do
it "should be successful" do
get 'show', :id=>@shop.user.nickname
response.should be_success
end
end
还有控制器:
def show
@user = User.find(:first,:conditions=>{:nickname=>params[:id]})
@shop = @user.shop
end
【问题讨论】:
-
对此有任何消息吗?我也遇到了这个最简单的问题。
标签: ruby-on-rails routing rspec