你好我是铁杆的英国人,英语不是我的主要语言,所以请耐心等待。
我一直在尝试使用我的rails应用程序中的一些路线 resource:name和let rails分配路由
我有这个routes.rb
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
get "signup", to: "users#new", as: "signup"
get "login", to: "sessions#new", as: "login"
get "logout", to: "sessions#destroy", as: "logout"
get 'sessions/:id', to: 'sessions#show'
get "dashboard", to: "dashboard#index", as: "dashboard"
resources :sites
resources :pages
resources :sitemaps
namespace :api, :defaults => { :format => 'json' } do
namespace :v1 do
resources :sessions, only: [:create,:show,:destroy]
resources :passwords, only: [:create,:update]
resources :users, only: [:create,:show,:update,:destroy]
end
end
end
我从我的视图中调用=link_to 'Add New Site', new_site_path, target: "_self"
此时站点加载但GET请求继续发送,导致它不断下载文件
我将发布一些来自FireBug / XHR控制台的GET请求
GET angular.js?body=1&_=1414486911946200 OK localhost:3000 760,9 KB 127.0.0.1:3000 4ms
GET index.js?body=1&_=1414486911947 200 OK localhost:3000 74 B 127.0.0.1:3000 3ms
GET inflector.js?body=1&_=1414486911948 200 OK localhost:3000 1,1 KB 127.0.0.1:3000 3ms
GET injector.js?body=1&_=1414486911949 200 OK localhost:3000 1,9 KB 127.0.0.1:3000 3ms
GET url_builder.js?body=1&_=1414486911950 200 OK localhost:3000 2,0 KB 127.0.0.1:3000 2ms
GET serialization.js?body=1&_=1414486911951 200 OK localhost:3000 25,2 KB 127.0.0.1:3000 2ms
EDIT 我已经注意到,如果我像这样得到它
get "add_site", to: "sites#new", as: "add_site"
并通过add_site_path调用它,这不会发生
答案 0 :(得分:1)
这是正常的 - 您发送的html包含对javascript文件的引用,浏览器需要单独下载它们。这里没什么好担心的。在生产中,资产由服务器直接提供,而不会触及应用程序,因此这些资产不会显示在生产日志中。