欢迎光临Software MyZone,有问题可留言或到站点论坛发帖,争取第一时间帮忙解决 || 站点论坛:火龙论坛 || 淘宝小店:应小心的易淘屋 【欢迎大家提建设性意见】

rspec 常见错误

1 、ActionView::Template::Error: Missing host to link to! Please provide :host parameter or set default_url_options[:host]
解决:config.action_mailer.default_url_options = { :host => ‘mywebsitename.com’ }

2、 routing:
实例:it “routes to #release” do
# post(“/admin/pickcontents/1/release”).should route_to(“admin/pickcontents#release”, :id => 1)
post(“/admin/pickcontents/1/release”).should route_to( :action => “release”,:controller => “admin/pickcontents”, :id => “1″)
end

错误信息:The recognized options <{“action”=>”release”, “controller”=>”admin/pickcontents”, “id”=>”1″}> did not match <{“id”=>1, “controller”=>”admin/pickcontents”, “action”=>”release”}>, difference: <{“id”=>1}>

路由配置: resources :pickcontents do
memeber do
post “release”
end
end
解析:当使用注释处报错,因为项的不匹配,要是使用member匹配的路由要单独制定controller或者anction

发表评论