In rails how to require a coffeescript file

53 Views Asked by At

In a rails application. I want to create a coffeescript function that can be shared by multiple coffeescripts.

for example

  1. app/assets/javascripts/util.js.coffee
sample_function = (word) -> console.log word
  1. app/assets/javascripts/sign_up/common.js.coffee

how to import and use the sample_function

I tried:

//= require '../util'
sample_function('hello world')

It says sample_function is undefined.

0

There are 0 best solutions below