Application#angular ...中的Sprockets :: FileNotFound找不到文件'lodash'

时间:2016-01-25 16:08:59

标签: ruby-on-rails angularjs restangular sprockets

有人能帮助我吗?我不知道我做错了什么......

总之,我在Rails中创建了一个应用程序,它使用AngularJS作为此AngularJS Tutorial之后的前端,并且它运行良好。

现在我想要做的是学会使用restangular(我认为需要lodash)来避免these种代码。要管理我使用Bower的前端依赖项,所以我按照标准步骤...

bower init
bower install angular angular-ui-router bootstrap lodash restangular --save

然后在//= require lodash//= require restangular之前的application.js中将'restangular'添加到角度模块依赖项...

现在问题当我运行rails时,我在浏览器中看到了这个...

enter image description here

我不明白为什么,似乎//= require lodash失败了,但我看到其他项目完全相同//= require lodash,所以我做错了什么?

bower.json

{
  "name": "flapper-news",
  "homepage": "https://github.com/*****/flapper-news",
  "authors": [
    "***** <*****@gmail.com>"
  ],
  "description": "",
  "main": "",
  "moduleType": [],
  "license": "MIT",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests",
    "vendor/assets/bower_components"
  ],
  "dependencies": {
    "angular": "~1.4.9",
    "angular-ui-router": "~0.2.16",
    "bootstrap": "~3.3.6",
    "AngularDevise": "angular-devise#~1.1.0",
    "lodash": "~4.0.1",
    "restangular": "~1.5.1"
  }
}

的application.js

//= require angular
//= require angular-rails-templates
//= require angular-ui-router
//= require AngularDevise
//= require angular-ui-notification
//= require lodash
//= require restangular
//= require_tree .

app.js

angular.module('flapperNews', ['ui.router', 'templates', 'Devise', 'restangular'])

.
.
.

请帮帮我:(

2 个答案:

答案 0 :(得分:2)

您是否在config/application.rb上添加了bower_component路径?

class Application < Rails::Application
  ...
  config.assets.paths << Rails.root.join('vendor', 'assets', 'bower_components')
  ...
end

http://joelencioni.com/blog/2014/01/03/integrating-bower-with-rails/

答案 1 :(得分:1)

你可以尝试

//= require lodash/dist/lodash