Giter VIP home page Giter VIP logo

coffee-rails's Introduction

Welcome to Rails

What's Rails?

Rails is a web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

Understanding the MVC pattern is key to understanding Rails. MVC divides your application into three layers: Model, View, and Controller, each with a specific responsibility.

Model layer

The Model layer represents the domain model (such as Account, Product, Person, Post, etc.) and encapsulates the business logic specific to your application. In Rails, database-backed model classes are derived from ActiveRecord::Base. Active Record allows you to present the data from database rows as objects and embellish these data objects with business logic methods. Although most Rails models are backed by a database, models can also be ordinary Ruby classes, or Ruby classes that implement a set of interfaces as provided by the Active Model module.

View layer

The View layer is composed of "templates" that are responsible for providing appropriate representations of your application's resources. Templates can come in a variety of formats, but most view templates are HTML with embedded Ruby code (ERB files). Views are typically rendered to generate a controller response or to generate the body of an email. In Rails, View generation is handled by Action View.

Controller layer

The Controller layer is responsible for handling incoming HTTP requests and providing a suitable response. Usually, this means returning HTML, but Rails controllers can also generate XML, JSON, PDFs, mobile-specific views, and more. Controllers load and manipulate models, and render view templates in order to generate the appropriate HTTP response. In Rails, incoming requests are routed by Action Dispatch to an appropriate controller, and controller classes are derived from ActionController::Base. Action Dispatch and Action Controller are bundled together in Action Pack.

Frameworks and libraries

Active Record, Active Model, Action Pack, and Action View can each be used independently outside Rails.

In addition to that, Rails also comes with:

  • Action Mailer, a library to generate and send emails
  • Action Mailbox, a library to receive emails within a Rails application
  • Active Job, a framework for declaring jobs and making them run on a variety of queuing backends
  • Action Cable, a framework to integrate WebSockets with a Rails application
  • Active Storage, a library to attach cloud and local files to Rails applications
  • Action Text, a library to handle rich text content
  • Active Support, a collection of utility classes and standard library extensions that are useful for Rails, and may also be used independently outside Rails

Getting Started

  1. Install Rails at the command prompt if you haven't yet:

    $ gem install rails
  2. At the command prompt, create a new Rails application:

    $ rails new myapp

    where "myapp" is the application name.

  3. Change directory to myapp and start the web server:

    $ cd myapp
    $ bin/rails server

    Run with --help or -h for options.

  4. Go to http://localhost:3000 and you'll see the Rails bootscreen with your Rails and Ruby versions.

  5. Follow the guidelines to start developing your application. You may find the following resources handy:

Contributing

We encourage you to contribute to Ruby on Rails! Please check out the Contributing to Ruby on Rails guide for guidelines about how to proceed. Join us!

Trying to report a possible security vulnerability in Rails? Please check out our security policy for guidelines about how to proceed.

Everyone interacting in Rails and its sub-projects' codebases, issue trackers, chat rooms, and mailing lists is expected to follow the Rails code of conduct.

License

Ruby on Rails is released under the MIT License.

coffee-rails's People

Contributors

allomov avatar arthurnn avatar darthdeus avatar etehtsea avatar guilleiguaran avatar inket avatar jasnow avatar jeroenvisser101 avatar jordimassaguerpla avatar josevalim avatar josh avatar junaruga avatar kaspth avatar larouxn avatar oliverklee avatar olleolleolle avatar orien avatar pda avatar prathamesh-sonpatki avatar rafaelfranca avatar richseviora avatar robertomiranda avatar robin850 avatar sanemat avatar spastorino avatar tenderlove avatar tpei avatar turadg avatar tuxdna avatar vfrride avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coffee-rails's Issues

"Coffee" namespace

I recently started a Rails app and I wanted to create a model called "Coffee". The coffee-rails gem prevented this from being possible. It would be nice if your Coffee module could be name-spaced to something else to allow me to have a Coffee model.

windows rails 5.0.1 require coffee/rails/js_hook

E:\railsworks\workspace\hello_app>rails s
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/coffee-rails-4.2.0/lib/coff
ee/rails/engine.rb:3:in require': cannot load such file -- coffee/rails/js_hook (LoadError) from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/coffee-rails-4 .2.0/lib/coffee/rails/engine.rb:3:in <top (required)>'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/coffee-rails-4
.2.0/lib/coffee-rails.rb:2:in require' from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/coffee-rails-4 .2.0/lib/coffee-rails.rb:2:in <top (required)>'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2
/lib/bundler/runtime.rb:77:in require' from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2 /lib/bundler/runtime.rb:77:in block (2 levels) in require'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2
/lib/bundler/runtime.rb:72:in each' from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2 /lib/bundler/runtime.rb:72:in block in require'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2
/lib/bundler/runtime.rb:61:in each' from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2 /lib/bundler/runtime.rb:61:in require'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.11.2
/lib/bundler.rb:99:in require' from E:/railsworks/workspace/hello_app/config/application.rb:7:in <top
(required)>'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1
/lib/rails/commands/commands_tasks.rb:88:in require' from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1 /lib/rails/commands/commands_tasks.rb:88:in block in server'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1
/lib/rails/commands/commands_tasks.rb:85:in tap' from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1 /lib/rails/commands/commands_tasks.rb:85:in server'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1
/lib/rails/commands/commands_tasks.rb:49:in run_command!' from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.1 /lib/rails/commands.rb:18:in <top (required)>'
from bin/rails:4:in require' from bin/rails:4:in

'

"undefined" compiles improperly?

The simple line:

if typeof emptyVar != "undefined"
  alert "not empty"

In Rails this gets compiled to:

if (typeof emptyVar !== void 0){
  return alert "not empty";
}

void 0 returns undefined while typeof emptyVar returns "undefined".

Is this expected behavior?

Unexpected compiler output

Expected

@test.method new Method
    key: value

to be (as per try coffeescript output)

this.test.method(new Method({
    collection: this.collection
}));

instead was

this.test.method(new Method)({
    collection: this.collection
});

Using coffee-rails 3.2.2

Add a changelog

If you could add a changelog that highlights key changes, deprecations, etc. for each release, that'd be extremely helpful. Commit logs tend to include a lot of extraneous info and usually only indicate what changed, not why. And in this one case, the tag for 3.2.0 doesn't exist yet, so it's not really clear where what revs to compare in the commit log either.

Chained functions calls aren't compiled correctly

With the latest version on rails 4.0, the following coffee script compiles incorrectly.

$stateProvider
  .state 'home', {
      url: '/'
      template: '<div>A</div>'
    }
  .state 'signin', {
      url: '/signin'
      template: '<div>B</div>'
      controller: 'SignInController'
    }

Expected:

$stateProvider.state('home', {
  url: '/',
  template: '<div>A</div>'
}).state('signin', {
  url: '/signin',
  template: '<div>B</div>',
  controller: 'SignInController'
});

Actual, invalid javascript produced:

$stateProvider.state('home', {
  url: '/',
  template: '<div>A</div>'
}.state('signin', {
  url: '/signin',
  template: '<div>B</div>',
  controller: 'SignInController'
}));

Looks like the latest coffee compilers (obtained via npm) don't have this issue. How can we update the gem to use the latest compilers?

version bump?

It's been since Oct '13. New version would be nice.

ActionView::MissingTemplate with no :coffee handlers

I'm really puzzled by two different machine rendering different results in ActionView templates. I've messaged @guilleiguaran and he suggested me posting it here so that we can discuss it with Santiago (@spastorino) and Jose (@josevalim).

On the problematic machine I have:

ActionView::MissingTemplate (Missing template availabilities/datetime, application/datetime with {:handlers=>[:erb, :builder], :formats=>[:js, :html], :locale=>[:en, :en]}.

and coffee isn't available. While on another it works completely fine. If I make up some random template extension on the good machine, then it'd say

ActionView::MissingTemplate (Missing template availabilities/datetime, application/datetime with {:handlers=>[:erb, :builder: coffee], :formats=>[:js, :html], :locale=>[:en, :en]}.

which is completely fine!! These are identical apps, running bundler, rails 3.1.1, just two different machine (both on Mac OSX Lion with node.js installed).

Guillermo asked me if I have different node.js installed but no, they both run node.js 0.4.12.

I've tried including therubyracer in the Gemfile as Guillermo suggested but it does not change the behavior.

Doesn't Register Sprockets Transformer or Mime Type

I've been familiarizing myself with Sprockets and how the Transformers and Processors work, but when I was trying to write a Preprocessor for Coffee I noticed I couldn't. I believe this gem handles converting Coffee to JS, but I was wondering why it uses an alternate route.

Is there any way to add preprocessors to it?

Problems using '\0' on Strings

Hi.

I'm having some problems using the '\0' character on Strings for example if I write:
console.debug("hello world\0")

I got this error
Uncaught Error: ExecJS::RuntimeError: SyntaxError: octal escape sequences "Hello World\0" are not allowed on line ...

but if I try the same on coffee from command line (from node) it work:
coffee> console.log("hello world\0")
hello world
undefined

coffee handler problems in production (Heroku)

I just ran into a problem where my create.js.coffee file was working in development but stopped working in production (on Heroku). The logs show that Rails isn't even looking for a coffee handler:

2011-10-14T08:26:29+00:00 app[web.1]: ActionView::MissingTemplate (Missing template page_blocks/create, application/create with {:handlers=>[:erb, :builder, :haml], :formats=>[:html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :locale=>[:nl, :nl]}. Searched in:
2011-10-14T08:26:29+00:00 app[web.1]:   * "/app/app/views"
2011-10-14T08:26:29+00:00 app[web.1]: ):

This is the (important) part of my Gemfile:

group :assets do
  gem "sass-rails", "~> 3.1.0"
  gem "coffee-rails", "~> 3.1.0"
  gem "uglifier"
  gem "compass", "~> 0.12.alpha"
end

# asset templates
gem "jquery-rails"
gem "haml"

Only after I moved coffee-rails outside of the :assets group, things started working. Perhaps it would be a good idea to somehow make this clear in the readme, and perhaps even ship Rails with the coffee-rails plugin being placed outside the assets group.

Coffee-script-source > 1.8.0 incompatible with x64_mingw

Using the latest version of this library on 64-bit windows raises an error when parsing coffeescript:

TypeError: Object doesn't support this property or method

This is because dependency coffee-script-source lost 64-bit windows compatability after version 1.8.0 (and still doesn't provide it with 1.12.0). For a full description of this issue and its trace, see this quite popular Stack Overflow post.

coffee-script-source doesn't provide a repo for raising issues. Can someone advise if there's a proper place to raise this issue with its maintainers, and if not, do the maintainers of this repo plan on solving this issue?

Additional layers of pre-processing, js.coffee.erb?

In the Ruby on Rails Asset Pipeline Guide they talk about preprocessing by chaining these preprocessors to the filename.

I can't seem to get it to work with coffee-rails however (meaning, not using it in the asset pipeline, but in js views for ajax callbacks).

Is this a known issue/limitation of this implementation at the moment? Or is there something else going on here?

/app/views/pages/update.js.coffee works
/app/views/pages/update.js.erb works (but I can't write in coffee script, obviously
/app/views/pages/update.js.coffee.erb does not work

2011-09-24 18:28:36 [INFO ] Completed 500 Internal Server Error in 290ms

ActionView::MissingTemplate (Missing template pages/update, application/update with {:handlers=>[:erb, :builder, :coffee, :haml], :formats=>[:js, "application/ecmascript", "application/x-ecmascript", :html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :locale=>[:nl, :nl]}. Searched in:
  * "/Users/Jean/nulvierdrie/manager/source/manager/app/views"
):


2011-09-24 18:28:36 [INFO ] Rendered /Users/Jean/.rvm/gems/ruby-1.9.3-preview1@manager/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (0.3ms)

ExternalInterface from Actionscript not working

Hey all,

Just found a bug, and I'm not sure if it's Coffeescript or if it's coffee-rails. When you're using ExternalInterface in a .swf file to call a Javascript function, the function is being ignored. I had to convert my Coffee file back to Javascript for the .swf to work.

Just a heads up.

Need new version of coffee-rails for Rails 5.2.0.alpha

Need new version of coffee-rails for edge ("master") Rails (5.2.0.alpha).
Currently getting:

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    coffee-rails was resolved to 3.1.0, which depends on
      railties (~> 3.1.0.rc1)

    rails was resolved to 5.2.0.alpha, which depends on
      railties (= 5.2.0.alpha)

    sass-rails was resolved to 5.0.6, which depends on
      railties (< 6, >= 4.0.0)

Can you release a new version that doesn't depend on railties 4.0.0.rc2

A brand new Rails 4 project reports this error:

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    rails (= 4.0.0) ruby depends on
      railties (= 4.0.0) ruby

    coffee-rails (= 4.0.0) ruby depends on
      railties (4.0.0.rc2)

The git repo shows this is fixed in master. Who can release a new version to rubygems?

Thanks!

Rails 3.2.rc2 - line 8: missing name after . operator

Not sure if its a coffee-rails issue but I have just tried to use rails 3.2.rc2 and when I create a new application and a controller and then go to the controller action I get the following

js: "/tmp/execjs20120110-20011-1fp3p2u.js", line 8: missing name after . operator

Anyone else getting the same?

GemFile is std rails generated with nothing added. ( removed commented lines for clarity)

source 'https://rubygems.org'
gem 'rails', '3.2.0.rc2'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '> 3.2.3'
gem 'coffee-rails', '
> 3.2.0'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'

html format being rendered on a js request

Steps to reproduce

  1. Create a new rails 5 project. rails new bug
  2. Generate a controller for sessions. rails generate controller sessions new
  3. Confirm that there are 2 views for Sessions#new. new.html.erb, new.coffee
  4. Generate a controller for a protected page. rails generate controller home index
  5. Add a redirect to home#index redirect_to 'sessions/new'
  6. run development server rails s
  7. Opening http://localhost:3000/home/index redirects to sessions#new using html template
  8. Opening http://localhost:3000/home/index.js redirects to sessions#new using html template
  9. Rename new.coffee for the sessions view to new.js.erb. mv app/views/sessions/new.coffee app/views/sessions/new.js.erb
  10. Opening http://localhost:3000/home/index redirects to sessions#new using html template
  11. Opening http://localhost:3000/home/index.js redirects to sessions#new using js template

Expected behavior

If the file app/views/sessions/new.coffee is present opening http://localhost:3000/home/index.js should redirect to sessions#new and use the js compiled from the coffee template.

Actual behavior

Tell us what happens instead

The html template is rendered instead the coffee template

This is the log output:

If the file app/views/sessions/new.coffee is present

Started GET "/home/index" for 127.0.0.1 at 2016-11-18 09:57:19 -0200
Processing by HomeController#index as JS
Redirected to http://localhost:3000/sessions/new

Started GET "/login" for 127.0.0.1 at 2016-11-18 09:57:20 -0200
Processing by SessionController#new as JS
  Rendering admin/session/new.html.erb
  Rendered admin/session/new.html.erb (5.2ms)
Completed 200 OK in 42ms (Views: 34.4ms | ActiveRecord: 0.0ms)

If the file app/views/sessions/new.js.erb is present

Started GET "/home/index" for 127.0.0.1 at 2016-11-18 09:41:34 -0200
Processing by HomeController#index as JS
Redirected to http://localhost:3000/sessions/new

Started GET "/login" for 127.0.0.1 at 2016-11-18 09:41:35 -0200
Processing by SessionController#new as JS
  Rendering admin/session/new.js.erb
  Rendered admin/session/new.js.erb (3659.3ms)
Completed 200 OK in 3846ms (Views: 3835.5ms | ActiveRecord: 0.0ms)

If the file app/views/sessions/new.coffee is present and the file app/views/sessions/new.html.erb is not present

Started GET "/home/index" for 127.0.0.1 at 2016-11-18 09:58:45 -0200
Processing by HomeController#index as JS
Redirected to http://localhost:3000/sessions/new

Started GET "/login" for 127.0.0.1 at 2016-11-18 09:58:45 -0200
Processing by SessionController#new as JS
  Rendering admin/session/new.coffee
  Rendered admin/session/new.coffee (636.9ms)
Completed 200 OK in 668ms (Views: 659.3ms | ActiveRecord: 0.0ms)

System configuration

Rails version:
Rails 5.0.0.1

Ruby version:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]

Gem list:

*** LOCAL GEMS ***

actioncable (5.0.0.1)
actionmailer (5.0.0.1)
actionpack (5.0.0.1)
actionview (5.0.0.1)
activejob (5.0.0.1)
activemodel (5.0.0.1)
activerecord (5.0.0.1)
activesupport (5.0.0.1)
arel (7.1.4)
bcrypt (3.1.11)
bigdecimal (1.2.8)
builder (3.2.2)
bullet (5.4.2)
bundler (1.13.6)
bundler-unload (1.0.2)
byebug (9.0.6)
coffee-rails (4.2.1)
coffee-script (2.4.1)
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
debug_inspector (0.0.2)
did_you_mean (1.0.0)
erubis (2.7.0)
execjs (2.7.0)
executable-hooks (1.3.2)
ffi (1.9.14)
gem-wrappers (1.2.7)
globalid (0.3.7)
i18n (0.7.0)
io-console (0.4.5)
jbuilder (2.6.0)
jquery-rails (4.2.1)
json (1.8.3)
kgio (2.10.0)
listen (3.0.8)
loofah (2.0.3)
mail (2.6.4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (3.2016.0521)
mina (1.0.3)
mina-npm (1.0.0.beta2)
mini_portile2 (2.1.0)
minitest (5.9.1, 5.8.3)
multi_json (1.12.1)
net-telnet (0.1.1)
newrelic_rpm (3.17.1.326)
nio4r (1.2.1)
nokogiri (1.6.8.1)
open4 (1.3.4)
pg (0.19.0)
power_assert (0.2.6)
psych (2.0.17)
puma (3.6.0)
rack (2.0.1)
rack-test (0.6.3)
rails (5.0.0.1)
rails-dom-testing (2.0.1)
rails-html-sanitizer (1.0.3)
railties (5.0.0.1)
raindrops (0.17.0)
rake (11.3.0, 10.4.2)
rb-fsevent (0.9.8)
rb-inotify (0.9.7)
rdoc (4.2.1)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
sass (3.4.22)
sass-rails (5.0.6)
spring (2.0.0)
spring-watcher-listen (2.0.1)
sprockets (3.7.0)
sprockets-rails (3.2.0)
sqlite3 (1.3.12)
test-unit (3.1.5)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.5)
turbolinks (5.0.1)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
uglifier (3.0.3)
unicorn (5.2.0)
uniform_notifier (1.10.0)
web-console (3.4.0)
websocket-driver (0.6.4)
websocket-extensions (0.1.2)

Additional Information

On my development machine, because I have a new.html with actual content this is the output when I open /login.js

Started GET "/login.js" for 127.0.0.1 at 2016-11-18 10:12:18 -0200
Processing by Admin::SessionController#new as JS
  Parameters: {"subdomain"=>"admin"}
  Rendering admin/session/new.html.erb
  Rendered admin/session/new.html.erb (6.1ms)
Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-origin JavaScript embedding.
Completed 422 Unprocessable Entity in 44ms (Views: 22.9ms | ActiveRecord: 0.0ms)

ActionController::InvalidCrossOriginRequest (Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-origin JavaScript embedding.):

actionpack (5.0.0.1) lib/action_controller/metal/request_forgery_protection.rb:239:in `verify_same_origin_request'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:382:in `block in make_lambda'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:218:in `block in halting'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:456:in `block in call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:456:in `each'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:456:in `call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.0.0.1) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.0.0.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `instrument'
actionpack (5.0.0.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.0.0.1) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
activerecord (5.0.0.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (5.0.0.1) lib/abstract_controller/base.rb:126:in `process'
actionview (5.0.0.1) lib/action_view/rendering.rb:30:in `process'
actionpack (5.0.0.1) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (5.0.0.1) lib/action_controller/metal.rb:262:in `dispatch'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:39:in `block in serve'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:26:in `each'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:26:in `serve'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:725:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
bullet (5.4.2) lib/bullet/rack.rb:10:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/rack/browser_monitoring.rb:32:in `traced_call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/etag.rb:25:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/conditional_get.rb:25:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/head.rb:12:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/session/abstract/id.rb:222:in `context'
rack (2.0.1) lib/rack/session/abstract/id.rb:216:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/cookies.rb:613:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
activerecord (5.0.0.1) lib/active_record/migration.rb:552:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
web-console (3.4.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.4.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.4.0) lib/web_console/middleware.rb:18:in `catch'
web-console (3.4.0) lib/web_console/middleware.rb:18:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
railties (5.0.0.1) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `block in tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `tagged'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/method_override.rb:22:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/runtime.rb:22:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
activesupport (5.0.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/static.rb:136:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
railties (5.0.0.1) lib/rails/engine.rb:522:in `call'
newrelic_rpm (3.17.1.326) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/handler/webrick.rb:86:in `service'
/Users/nicoskaralis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
/Users/nicoskaralis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
/Users/nicoskaralis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'
  Rendering /Users/nicoskaralis/.rvm/gems/ruby-2.3.1@connect-ads-channel-server/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
  Rendering /Users/nicoskaralis/.rvm/gems/ruby-2.3.1@connect-ads-channel-server/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
  Rendered /Users/nicoskaralis/.rvm/gems/ruby-2.3.1@connect-ads-channel-server/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (14.9ms)
  Rendering /Users/nicoskaralis/.rvm/gems/ruby-2.3.1@connect-ads-channel-server/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
  Rendered /Users/nicoskaralis/.rvm/gems/ruby-2.3.1@connect-ads-channel-server/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (4.7ms)
  Rendering /Users/nicoskaralis/.rvm/gems/ruby-2.3.1@connect-ads-channel-server/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
  Rendered /Users/nicoskaralis/.rvm/gems/ruby-2.3.1@connect-ads-channel-server/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (11.5ms)
  Rendered /Users/nicoskaralis/.rvm/gems/ruby-2.3.1@connect-ads-channel-server/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (110.8ms)

Originally opened on rails/rails#27095

Release 4.1.0

I don't feel comfortable doing this myself since I don't have rubygems.org (and thats fine). If one of you could do the honors please. Everything should be ready to go besides the version bump and rubygems push.

Thanks!

cc @rafaelfranca @spastorino

rake aborted! while doing precompile

I am trying to precompile my rails project i am getting below error.
rake aborted!
Error: Out of stack space
(in ..Ruby193/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts/coffee-script.js.erb)
when i comment coffee-rails gem precompile work fine.
ruby 1.9
rails 3.2
coffee-rails (3.2.2)
Please check is there any problem in coffee-rails gem.still i am getting same issue.

Thank you

Provide new release

Looks like it is time for new release.

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    coffee-rails (~> 4.2) was resolved to 4.2.0, which depends on
      railties (< 5.2.x, >= 4.0.0)

Rails 5.2.0.alpha

Not showing line numbers for compile errors with CoffeeScript >= 1.6.2

Error message with gem 'coffee-script-source', '1.6.1'

ExecJS::ProgramError in Pages#index
Showing SomeApp/app/views/layouts/application.html.slim where line #7 raised:

Error: In example.js.coffee, Parse error on line 5: Unexpected 'INDENT'
  (in SomeApp/app/assets/javascripts/example.js.coffee)

Error message with gem 'coffee-script-source', '1.6.2'

ExecJS::RuntimeError in Pages#index
Showing SomeApp/app/views/layouts/application.html.slim where line #7 raised:

SyntaxError: unexpected INDENT
  (in SomeApp/app/assets/javascripts/example.js.coffee)

Cannot set property 'root' of null

I run a Rails 4.1.0 app and an error occur randomly on precompile during deploy (with mina) or directly throw by local server, etc... this is not yet on production but it could happen on it as well.

The file compiled when this error occurs is different each time, and the error is thrown randomly without any changes to source code.

ExecJS::ProgramError: TypeError: Cannot set property 'root' of null

This error happened using therubyracer 0.12.1 as JS runtime, I did not test it with another runtime yet

This issue has been referenced here jashkenas/coffeescript#3829
The full stack trace I get from Mina on deploy:

ExecJS::ProgramError: TypeError: Cannot set property 'root' of null
(in /home/deploy/tmp/build-142485688618988/app/assets/javascripts/controllers/selections_ctrl.js.coffee)
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/execjs-2.3.0/lib/execjs/ruby_racer_runtime.rb:58:in `rescue in block in call'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/execjs-2.3.0/lib/execjs/ruby_racer_runtime.rb:52:in `block in call'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/execjs-2.3.0/lib/execjs/ruby_racer_runtime.rb:87:in `block in lock'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/execjs-2.3.0/lib/execjs/ruby_racer_runtime.rb:85:in `call'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/execjs-2.3.0/lib/execjs/ruby_racer_runtime.rb:85:in `Locker'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/execjs-2.3.0/lib/execjs/ruby_racer_runtime.rb:85:in `lock'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/execjs-2.3.0/lib/execjs/ruby_racer_runtime.rb:51:in `call'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/coffee-script-2.3.0/lib/coffee_script.rb:76:in `compile'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/tilt-1.4.1/lib/tilt/coffee.rb:46:in `evaluate'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:197:in `block in evaluate'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:194:in `each'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:194:in `evaluate'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:12:in `initialize'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:374:in `new'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:374:in `block in build_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:395:in `circular_call_protection'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:373:in `build_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:94:in `block in build_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/caching.rb:58:in `cache_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:93:in `build_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:287:in `find_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:61:in `find_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/bundled_asset.rb:16:in `initialize'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:377:in `new'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:377:in `build_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:94:in `block in build_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/caching.rb:58:in `cache_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:93:in `build_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:287:in `find_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:61:in `find_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:211:in `block in find_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:257:in `benchmark'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:210:in `find_asset'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:119:in `block in compile'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:118:in `each'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:118:in `compile'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.3/lib/rake/sprocketstask.rb:146:in `with_logger'
/home/deploy/tmp/build-142485688618988/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'

coffee-rails 3.1.1 test failure

I'm getting the following test failure with coffee-rails 3.1.1:

  1) Failure:
test_coffee_views_are_served_as_javascript(TemplateHandlerTest)
    []:
<"(function() {\n\n  alert('hello world');\n\n}).call(this);\n"> expected to be =~
</\(function\(\)\ \{\n\ \ alert\('hello\ world'\);\n\}\)\.call\(this\);\n/>.

The failure looks innocent enough since it only seems to differ in whitespace.

Rails 3.1.3, coffee-script 2.2.0, ruby 1.8.7. Please let me know if you need more info.

dependency on railties 3.2.0.beta?

This is an unexpected dependency...

gem update         
Updating installed gems
Updating coffee-rails
ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: coffee-rails requires railties (~> 3.2.0.beta)

How are asset-defined methods called from a view?

I'm confused on how to call a function foo defined in app/assets/javascripts/foo_file.coffee. I get ReferenceError: foo is not defined

foo = (x, y) ->
  alert('this is foo')

#alert('top level alert')

from a view that uses .slim and coffeescript with:

coffee:
  $ ->
    $(document).on "turbolinks:load", ->
      foo('a', '#b')

I know the foo.coffee is loaded, as I can see the top-level alert commented out in that file.

I have used CS with SLIM in this fashion extensively before and it's great, but always with ajax hooks, etc.. Now I want to move some of the code from pages to a common file in the proper place, but calling it seems to be that I need a little something to make that happen.

Suggestions?

Support for literate coffeescript?

CoffeeScript 1.5 added support for literate coffeescript โ€“ a new dialect in which the file is a valid markdown document, where the indented code blocks are treated as actual coffeescript (and everything else is treated as comments).

The 'official' file extensions for this are .litcoffee and .coffee.md (the latter added in CoffeeScript 1.6.1). If you use the command line coffee tool to compile a file with either of these extensions, it treats it as literate coffeescript.

When I use either of these extensions in Rails, I just get Sprockets::FileNotFound.

Reserves the constant name Coffee

I have a Rails application that needs to use the constant name Coffee, but am unable to do so because of coffee-rails. Could this name be changed to something more specific like CoffeeRails?

Support For CoffeeScript Partials?

Are there plans to support partials made in CoffeeScript? As it stands, if I have blah.js.coffee, and in it I attempt to call:

<%= render partial: 'meh.js.coffee' %>

It results in something similar to this:

ActionView::Template::Error (reserved word "class" can't be assigned on line 1):

Another variation is for it to say reserved word "function" can't be assigned.

Thoughts? Or, are people generally moving away from JavaScript/CoffeeScript in ERB files?

Can't install Edge Rails(4.0.0.beta)

An error occured, when I tried installing edge rails.

Updating git://github.com/rails/coffee-rails.git
Fetching gem metadata from https://rubygems.org/.......
Could not find gem 'coffee-rails (~> 4.0.0.beta) ruby' in git://github.com/rails/coffee-rails.git (at master).
Source contains 'coffee-rails' at: 3.2.0

my environments:

$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
$ rails/rails/railties/bin/rails -v
Rails 4.0.0.beta

I may be wrong but it worked when changed like this.

diff --git a/lib/coffee/rails/version.rb b/lib/coffee/rails/version.rb

index 90dbccd..21202a0 100644
--- a/lib/coffee/rails/version.rb
+++ b/lib/coffee/rails/version.rb
@@ -1,5 +1,5 @@
module Coffee
module Rails

  • VERSION = "3.2.0"
  • VERSION = "4.0.0.beta"
    end
    end

Feature request: asset_path helper

Hello, I would like to see a asset_path helper.

$('#foo').attr src: asset_path('foo.png')

becomes:

$('#foo').attr({
  src: '/assets/foo.png'
});

Execjs Errors Not Showing File Location

Hi, I did fresh install rails 4.2.5 with coffee-rails 4.1.0 and when there is syntax error on my .coffee file, the error only shows error message without the filename on which file the error happen.

SyntaxError: [stdin]:2:1: unexpected indentation

.litcoffee support

Naming a file "foo.js.litcoffee" or "foo.js.coffee.md" do not work. How can I get literate coffeescript support?

All Ruby's Tests failed because of NameError: uninitialized constant ActionView::DependencyTracker

I would share you that current master branch's tests are failed.
https://travis-ci.org/rails/coffee-rails/branches

Below are latest build for master branch.
https://travis-ci.org/rails/coffee-rails/builds/228967808

For example about Ruby 2.4.0
https://travis-ci.org/rails/coffee-rails/jobs/228967838

$ bundle exec rake
...
TemplateHandlerTest#test_coffee_views_are_served_as_javascript:
NameError: uninitialized constant ActionView::DependencyTracker
...

ExecJS::RuntimeError in Users#index ( 'coffee-rails', '~> 3.1.1' and execjs version is 1.2.12' )

Gemfile

gem 'rails', '3.1.1'

group :assets do
gem 'sass-rails', '> 3.1.4'
gem 'coffee-rails', '
> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end

execjs is 1.2.12

============ Error i am getting in console =============

js: "/tmp/execjs20111224-11813-dzulxb.js", line 508: missing } after function body
js: });
js: ..^

(in /home/manoj/Documents/RailsProject/SmartCollege/app/assets/javascripts/course_subjects.js.coffee)):
3:
4: <title>edge</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%#= csrf_meta_tags %>
8:
9:

================== In Browser ==================

ExecJS::RuntimeError in Users#index

js: "/tmp/execjs20111224-12170-kah3u0.js", line 8: missing name after . operator
js: (function(root){var CoffeeScript=function(){function require(a){return require[a]}require["./helpers"]=new function(){var

.
.
.

js: "/tmp/execjs20111224-12170-kah3u0.js", line 508: missing } after function body
js: });
js: ..^

(in /home/manoj/Documents/RailsProject/SmartCollege/app/assets/javascripts/course_subjects.js.coffee)

Rails asset helper function

I'm building an AngularJS app and there are asset URLs all over the code.

Any chance of implementing a helper function that will execute Sprockets' asset_path and return it as a string in the output JS code?

Similar to how sass-rails (https://github.com/rails/sass-rails) adds this helper function to SASS.

"WHEN" keyword not parsed correctly when used as a key

Hello,

I'm using a flipbook js library called turn.js. This library uses certain keys when creating the flibooks. For example in normal js it would be like this:

$(flipbook).turn({
   width: 922,
   height: 600,
   autoCenter: true,
   pages: 12,
   when: {
       turning: function(event, page, view) {
       }
   }
});

If I use coffeescript it goes like this:

$(flipbook).turn
    width:922,
    height:600,
    autoCenter: true,
    pages: 12,
    when:
        turning: (event, page, view)  ->

But it ends up parsing like this:

$(flipbook).turn({
          width: 912,
          height: 650,
          elevation: 50,
          gradients: true,
          autoCenter: true
        }, {
          when: {
            turning: function(event, page, view) {
            }
         }
      }
 );

I'm guessing it is a problem with the WHEN keyword being recognized as a special word for the switch instruction. I'm also going to post this issue in the coffeescript repo.

Thanks

Tests failing under Ruby 1.9.3

Hi, I have a test failure running Ruby 1.9.3 with coffe-rails 3.2.2:

  1. Failure:
    test_coffee-script.js_is_included_in_Sprockets_environment(AssetsTest) [/builddir/build/BUILD/ruby193-rubygem-coffee-rails-3.2.2/opt/rh/ruby193/root/usr/share/gems/gems/coffee-rails-3.2.2/test/assets_test.rb:28]:
    Expected /this.CoffeeScript/ to match "/**\n * CoffeeScript Compiler v1.2.0\n * http://coffeescript.org\n *\n * Copyright 2011, Jeremy Ashkenas\n * Released under the MIT...

and this goes on for pages of the compiled javascript.
Any idea what went wrong?

Thanks!

Add ability to indent ruby in coffee with erb

Hi, thanks for all the work on this gem.

I would like to discuss about indenting coffee script when erb is present.

form = document.getElebentById('form') 

<% if @response.present? %>
   form.token.value = '<%= @response[:token] %>'
<% end %>

<% if params[:code].present? %>
  App.openDoor()
<% end %>

However, coffee will complain about mismatching indentation.

Do you have any idea how could we make this kind of syntax valid ?

cc @fonji

Bare option for selected files

I want to express this CommonJS pattern in coffeescript
http://requirejs.org/docs/whyamd.html#sugar

define(function (require) {
    var dependency1 = require('dependency1'),
        dependency2 = require('dependency2');

   var Foo = .....
   return Foo;
});

the problem is that cofee compiler wraps my code into an anonymous function, which prevents r.js optimized to detect the pattern. I want to avoid this for selected files (those that are AMD modules). Is there a way to run a compiler with the "--bare" option for selected files?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.