初めてアプリケーションを本番環境に移行したとき、いくつかの問題が見つかりました。プリコンパイルされたアセットを本番環境で使用する必要があることがわかったので、それらをコンパイルしようとしましたが、次のエラーが発生しました。
rake aborted!
/var/www/tracker/app/assets/templates/snippets/comment.html.erb has already been required
(in /var/www/tracker/app/assets/javascripts/angularjs/routes.coffee.erb)
ここで最も紛らわしいのは、ファイルcomment.html.erb
が routes.coffee.erb でまったく言及されていないことです。これには、 angularjsのいくつかのルートが含まれているだけです。
angular.module('app', ['ui', 'app.services', 'app.directives', 'app.filters', 'ngCookies', 'ngSanitize', 'mwTable'])
.config ['$routeProvider', ($routeProvider) ->
$routeProvider.when '/',
templateUrl: '<%= asset_path('announces/list.html') %>'
controller: AnnouncesListCtrl
$routeProvider.when '/announce/:fid',
templateUrl: '<%= asset_path('announces/view.html') %>'
controller: AnnouncesViewCtrl
$routeProvider.when '/announce/:fid/edit',
templateUrl: '<%= asset_path('announces/edit.html') %>'
controller: AnnouncesEditCtrl
$routeProvider.when '/registration',
templateUrl: '<%= asset_path('users/edit.html') %>'
controller: UsersEditCtrl
$routeProvider.when '/registration_successful',
templateUrl: '<%= asset_path('users/registration_successful.html') %>'
controller: UsersEditCtrl
$routeProvider.when '/users',
templateUrl: '<%= asset_path('users/list.html') %>'
controller: UsersListCtrl
$routeProvider.otherwise({redirectTo: '/'})
]
私が考えることができる唯一のことは、私が使用し<%= asset_path('announces/view.html') %>
たことであり、これには が含まれています<%= asset_path('snippets/comment.html')%>
。これが問題の原因である場合、考えられる唯一の解決策は使用しないことasset_path
です。でも、それでいいの?
完全なエラー メッセージはこちら: https://gist.github.com/SET/5167092。そのサイズにもかかわらず、それは99%役に立たない.
また、私は Rails (PHP から来た) を初めて使用するので、何かが既に必要であることがなぜそれほど重要なのか理解できません。数回必要ですが、ロードするのは 1 回だけです。なぜこれが問題を引き起こすのでしょうか?
更新: <%= asset_path(template) %>` を '/assets/template' に置き換えて問題を解決しましたが、それは醜い解決策ではありませんか?