I'm developing an webapplication with rails 4 and spine js as the frontend mvc framework. With gem 'spine-rails' installed, I ran the command
rails g spine:new
And in the app folder generated, the index.js.coffee file load some 3rd party assets.
#= require json2
#= require jquery
#= require spine
#= require spine/manager
#= require spine/ajax
#= require spine/route
#= require_tree ./lib
#= require_self
#= require_tree ./models
#= require_tree ./controllers
#= require_tree ./views
class Frontend extends Spine.Controller
constructor: ->
super
# Initialize controllers:
# @append(@items = new Frontend.Items)
# ...
Spine.Route.setup()
window.Frontend = Frontend
when running the server, here comes an error that
Sprockets::FileNotFound at /
couldn't find file 'json2' (in /Users/edward/git/beta-cafe/app/assets/javascripts/frontend/index.js.coffee:1)
It seems that there js files like json2, spine, spine/ajax, are loaded in the gem folder.But Rails fails to load them.
Any solutions? :)
Add
gem 'json2-rails'to your gemfile.This solved the same issue for me. It shouldn't be necessary, though, because the spine-rails has that gem as a dependency.
Edit
After posting this answer, I confirmed my answer when I happened to look at the spine-rails github repo while working on another project. It says:
So you must include the json2-rails gem in your gemfile.