Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 未捕获引用错误:未在Rails 4上定义JST_Ruby On Rails_Backbone.js_Jst - Fatal编程技术网

Ruby on rails 未捕获引用错误:未在Rails 4上定义JST

Ruby on rails 未捕获引用错误:未在Rails 4上定义JST,ruby-on-rails,backbone.js,jst,Ruby On Rails,Backbone.js,Jst,我创建了Rails4.2项目,并尝试将主干网用于前端。 但当我尝试将JST用于模板时,我得到了以下错误 Uncaught ReferenceError: JST is not defined 当然,我在application.js文件中包含了相应的需求集,如下所示 //= require jquery //= require jquery_ujs //= require underscore //= require hamlcoffee //= require backbone //= req

我创建了Rails4.2项目,并尝试将主干网用于前端。 但当我尝试将JST用于模板时,我得到了以下错误

Uncaught ReferenceError: JST is not defined
当然,我在application.js文件中包含了相应的需求集,如下所示

//= require jquery
//= require jquery_ujs
//= require underscore
//= require hamlcoffee
//= require backbone
//= require backbone.marionette
//
//= require_tree ../templates/
//= require ./myapp
//= require ./models
//= require ./views
//= require ./controllers
//
//= require_tree .
我使用的JST文件如下所示

Backbone.Marionette.Renderer.render = (template, data) ->
  console.log "rendering template #{template}"
  if (!JST[template])
    throw "Template '#{template}' not found!"
  JST[template](data)
这是我的档案

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

gem 'bootstrap-sass', '3.2.0.0'
gem 'marionette-rails'
gem 'bcrypt',         '3.1.7'
gem 'haml_coffee_assets'
gem 'execjs'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end
源代码'https://rubygems.org'
#捆绑边缘Rails:gem'Rails',github'Rails/Rails'
gem“rails”、“4.2.0”
#使用sqlite3作为活动记录的数据库
gem'sqlite3'
#将SCS用于样式表
gem'sass-rails',“~>5.0”
#使用Uglifier作为JavaScript资产的压缩器
gem'uglifier','>=1.3.0'
#将CoffeeScript用于.coffee资产和视图
gem“咖啡轨”,“~>4.1.0”
#看https://github.com/sstephenson/execjs#readme 获取更多受支持的运行时
#宝石“therubyracer”,平台::ruby
#使用jquery作为JavaScript库
gem'jqueryrails'
#Turbolinks使web应用程序中的以下链接更快。阅读更多:https://github.com/rails/turbolinks
gem“涡轮链接”
#轻松构建JSON API。阅读更多:https://github.com/rails/jbuilder
gem'jbuilder',“~>2.0”
#bundle exec rake doc:rails在doc/API下生成API。
gem'sdoc','~>0.4.0',组::doc
#使用ActiveModel具有\u安全\u密码
#gem'bcrypt',“~>3.1.7”
#使用Unicorn作为应用程序服务器
#宝石“独角兽”
#使用Capistrano进行部署
#gem“capistrano rails”,集团::开发
gem“引导式sass”,“3.2.0.0”
宝石“木偶轨道”
gem“bcrypt”,“3.1.7”
宝石“哈姆咖啡资产”
gem'execjs'
小组:开发,:测试
#在代码中的任意位置调用“byebug”以停止执行并获得调试器控制台
宝石“比伯”
#在异常页面上或通过在视图中使用访问IRB控制台
gem“web控制台”,“~>2.0”
#Spring通过让应用程序在后台运行来加速开发。阅读更多:https://github.com/rails/spring
宝石“春天”
结束
正如您所看到的,我正在尝试将Rails 4.2用于主干组合。 所以,我希望知道Rails 4.2是否不支持主干JST文件,或者我是否需要什么来激活JST


请帮帮我

最后,我找到了JST未定义错误的原因。
这是因为JST文件路径(在我的例子中,路径=JST[“主干/apps/”+模板])出错。

尝试将
sprockets-rails
gem降级为
v=2.3.3


这对我很有帮助。

你从哪里得到错误?正如我在帖子中所写,我现在因为JST未定义错误而陷入困境。不,我的意思是,你从哪里得到错误?这是Ruby错误吗?还是Javascript错误?这是Javascript错误。当我运行Rails应用程序时,我通过javascript控制台发现了错误。Rails 4甚至支持主干JST吗?这是否意味着在Sprocket 3.0.0中不推荐JST?