RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: Svensklanemarknad
Site: lanemarknad.se
Wouldn't it make more sense to create a $JsProduct class object in an initializer and then call new on $JsProduct in the for_mustache method?
config/initializers/js_product.rb
coffee = File.read(Rails.root.join("app/assets/javascripts/product.js.coffee")) javascript = CoffeeScript.compile(coffee) c = V8::Context.new c.eval(javascript) $JsProduct = c.eval("Product")
models/product.rb
def for_mustache $JsProduct.new(to_json) end
Wouldn't it make more sense to create a $JsProduct class object in an initializer and then call new on $JsProduct in the for_mustache method?
config/initializers/js_product.rb
models/product.rb