Hyperionel
Hyperionel

Reputation: 11

Continous loading of resources after routing in rails

Hello I am a begginer with rails and english is not my main language so please bear with me through this.

I've been trying some routes in my rails app simply, using the resource: name and let rails assign the routes

I have this 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

I am calling =link_to 'Add New Site', new_site_path, target: "_self" from my view

At this point the site loads but GET requests keep on being sent resulting in it downloading files continously

I'll post some of the GET requests from the FireBug/XHR console

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 I have noticed that if I make a get for it like so

get "add_site", to: "sites#new", as: "add_site"

and call it throught the add_site_path this does not happen

Upvotes: 1

Views: 37

Answers (1)

BroiSatse
BroiSatse

Reputation: 44685

This is normal - the html you sent contains references to javascript files and browser needs to download them separately. Nothing to worry here. In production, assets are served directly by the server without touching application, so those will not show up in the production log.

Upvotes: 1

Related Questions