Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5947095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:54:58+00:00 2026-05-22T16:54:58+00:00

Under Rails 3.1, I’m trying to find out how to move a few coffeescript

  • 0

Under Rails 3.1, I’m trying to find out how to move a few coffeescript classes away from my controller default coffeescript file (home.js.coffee) into another file, in order to structure the whole a little bit.

Does anyone know how to “include” a coffeescript file into another?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:54:59+00:00Added an answer on May 22, 2026 at 4:54 pm

    What you want to do is export functionality. For instance, if you start with

    class Foo
      ...
    
    class Bar extends Foo
      ...
    

    and you decide you move Foo to its own file, that file should look like

    class Foo
      ...
    
    window.Foo = Foo
    

    (where window.Foo = Foo makes Foo a global), and Bar‘s file should start with the Sprockets directive

    #= require Foo
    

    (assuming that you’ve named Foo‘s file Foo.js.coffee). Each file is compiled into JS independently, but Sprockets will ensure that Foo is included before Bar.

    Note that, as a shortcut, you can get rid of the window.Foo = Foo line, and instead write

    class window.Foo
      ...
    

    or simply

    class @Foo
      ...
    

    to define a class named Foo that’s attached to the window object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to test a controller in my rails app under a specific
I'm trying to implement thinking-sphinx across multiple 'sites' hosted under a single rails application.
I'm trying to get a bare bones Rails app deployed under Apache, Passenger 3.0.0
I'm running Rails + Passenger under an Ubuntu AWS's instance. Now I'm trying to
I am trying to get LDAP authentication to work under Rails. I have chosen
There is a file under public folder in Rails environment called dispatch.fcgi . What
I looked in the Rails docs under inflector and found this message... Module deprecated
Under the View-Model-ViewModel pattern for WPF, I am trying to databind the Heights and
We're running a small JRuby on Rails app under Tomcat 6.0.28 with a Spring-based
We're running a small web application written JRuby on Rails running under Tomcat. We're

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.