【问题标题】:ember/rails app loading not loading properly (takes too long) in developmentember/rails 应用程序加载未正确加载(需要很长时间)在开发中
【发布时间】:2015-01-16 05:22:49
【问题描述】:

我有一个带有 rails 后端的新 ember-cli 应用程序。在开发中加载大约需要 30 多秒......这显然太长了。

我正在使用 ember-cli-rails gem https://github.com/rwz/ember-cli-rails

我正在使用 Rails 服务器(我尝试过 webrick 和 Thin)。我没有使用 ember 服务器,没有单独运行它们。

我没有使用 rails 资产管道。我已经删除了。

这是我的 Rails 配置/路线

Rails.application.routes.draw do

  resources :rewrites, contraints: { format: :json }
  resources :users, contraints: { format: :json }
  resources :movies, contraints: { format: :json }

  root 'application#index'

  namespace :api do
    get :csrf, to: 'csrf#index'
  end

  get "/*path" => "application#index", contraints: { format: :html }

这是我的 application.html.erb

<!DOCTYPE html>
<html>
  <head>
    <title>Better Films</title>
    <%= csrf_meta_tags %>
  </head>
  <body>

    <%= yield %>

  </body>
</html>

这是我的 application/index.html.erb,frontend 是我的 ember 应用程序的名称

<%= include_ember_script_tags :frontend %>
<%= include_ember_stylesheet_tags :frontend %>

当我访问 localhost 时,我的 rails 服务器日志显示了这个

Rendered application/index.html.erb within layouts/application (173.6ms)
Completed 200 OK in 203ms (Views: 202.6ms | ActiveRecord: 0.0ms)


Started GET "/assets/frontend/frontend.css?body=1" for 127.0.0.1 at 2015-01-15 23:13:28 -0600


Started GET "/assets/frontend/vendor.css?body=1" for 127.0.0.1 at 2015-01-15 23:13:39 -0600


Started GET "/assets/frontend/frontend.js?body=1" for 127.0.0.1 at 2015-01-15 23:13:49 -0600


Started GET "/assets/frontend/vendor.js?body=1" for 127.0.0.1 at 2015-01-15 23:14:00 -0600

web 检查器网络标签显示

【问题讨论】:

    标签: ruby-on-rails ember.js loading


    【解决方案1】:

    我不确定这是否相关,但是当我将 config/initializers/ember.rb 中的 ember 应用程序路径设置为 Rails.root.join('frontend').to_s 时,我遇到了同样的问题。当我删除路径选项时,一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-09
      • 1970-01-01
      相关资源
      最近更新 更多