铁轨6路线错误未定义的本地变量或方法
通过我的一些路线获取此错误。
未定义的本地变量或方法`export_on_demand_dictionary_processor_path'for #actionView :: base:0x0000000002ADA00 你的意思? export_on_demand_dictionary_processor_index_path
如何解决此错误,而不在所有路由路径中添加'索引'?
错误在URL路径上发生。
$.ajax({
type: 'POST',
url: "<%= export_on_demand_dictionary_processor_path %>",
data: $('#export_params_input').val() + '&' + $.param({'build_request_id' : $("#build_request_id").val()}),
success: function(data, text_status, xhr) {
window.location.href = data["new_href"];
$("#load_build_section :input").attr("disabled", false);
$("#export_progress_message").hide();
},
error: function(xhr) {
$("#load_build_section :input").attr("disabled", true);
$("#export_progress_message").html("Export failed. (HTTP " + xhr.status + ")");
}
})
这就是我的路线。RB的样子。
resources :dictionary_processor, :as => :dictionary_processor, :only => [] do
collection {
get 'import';
get 'propose_on_demand';
post 'run_import';
get 'propose_build';
post 'export_on_demand';
}
Getting this error with some of my routes.
undefined local variable or method `export_on_demand_dictionary_processor_path' for #ActionView::Base:0x0000000002ada0
Did you mean? export_on_demand_dictionary_processor_index_path
How do I fix this error without adding 'index' to all the route paths?
Error happens on the url path.
$.ajax({
type: 'POST',
url: "<%= export_on_demand_dictionary_processor_path %>",
data: $('#export_params_input').val() + '&' + $.param({'build_request_id' : $("#build_request_id").val()}),
success: function(data, text_status, xhr) {
window.location.href = data["new_href"];
$("#load_build_section :input").attr("disabled", false);
$("#export_progress_message").hide();
},
error: function(xhr) {
$("#load_build_section :input").attr("disabled", true);
$("#export_progress_message").html("Export failed. (HTTP " + xhr.status + ")");
}
})
This is what my route.rb looks like.
resources :dictionary_processor, :as => :dictionary_processor, :only => [] do
collection {
get 'import';
get 'propose_on_demand';
post 'run_import';
get 'propose_build';
post 'export_on_demand';
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将
资源
更改为资源
或dictionary_processor
dictionary_processors
。名称的单数和复数在铁轨中很重要。请小心,因为控制器名称将变为复数。
更改之前和之后,您可以使用命令检查路线以查看已更改的内容
You can change
resources
toresource
ordictionary_processor
todictionary_processors
. Singular and plural in names are important in rails.Just be careful because the controller name will change to plural.
Before and after the change, you can check your routes with a command to see what has changed