Ruby on rails 没有与[GET]匹配的路由/flare.json“;
我使用的示例来自Ruby on rails 没有与[GET]匹配的路由/flare.json“;,ruby-on-rails,json,d3.js,rails-routing,Ruby On Rails,Json,D3.js,Rails Routing,我使用的示例来自D3.js,它使用D3.json函数在Rails中加载flare.json。 我的视图所在的文件夹中有flare.json文件。加载页面时,出现以下错误: ActionController::RoutingError (No route matches [GET] "/flare.json"): 如何告诉rails将此请求路由到flare.json文件 这是预加载的代码: d3.json("flare.json", function(error, root) { var n
D3.js
,它使用D3.json
函数在Rails中加载flare.json
。
我的视图所在的文件夹中有flare.json
文件。加载页面时,出现以下错误:
ActionController::RoutingError (No route matches [GET] "/flare.json"):
如何告诉rails将此请求路由到flare.json文件
这是预加载的代码:
d3.json("flare.json", function(error, root) {
var node = svg.selectAll(".node")
.data(bubble.nodes(classes(root))
.filter(function(d) { return !d.children; }))
.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
node.append("title")
.text(function(d) { return d.className + ": " + format(d.value); });
node.append("circle")
.attr("r", function(d) { return d.r; })
.style("fill", function(d) { return color(d.packageName); });
node.append("text")
.attr("dy", ".3em")
.style("text-anchor", "middle")
.text(function(d) { return d.className.substring(0, d.r / 3); });
});
谢谢大家! 在路由添加条目中:
match "flare" => "some_controller#index"
在控制器中:
def index
respond_to do |format|
format.json { render :json => { 1 => "First", 2 => "Second"} }
end
end