Put coffee-rails in top-level of generated Gemfile #9881

Merged
merged 1 commit into from Mar 25, 2013

Projects

None yet

6 participants

@gkop
Contributor
gkop commented Mar 23, 2013

The goal is for a vanilla app to render coffee templates in production the same as it does in development and test. As far as I can tell, that simply means moving coffee-rails from :assets to the top-level.

@steveklabnik steveklabnik commented on the diff Mar 23, 2013
railties/lib/rails/generators/app_base.rb
@@ -178,29 +178,25 @@ def assets_gemfile_entry
return if options[:skip_sprockets]
gemfile = if options.dev? || options.edge?
- <<-GEMFILE
+ <<-GEMFILE.gsub(/^ {12}/, '')
@gkop
gkop Mar 23, 2013 Contributor

Not the same thing. gsub'ing works even when you interpolate "\n" in the heredoc (causing the following line to start at column 0).

@steveklabnik
Member

You shouldn't need to do this; assets gems belong in the assets group. To turn on asset compilation in production just

config.assets.compile = true

http://guides.rubyonrails.org/asset_pipeline.html#live-compilation

@josevalim
Member

Yes, Rails default strategy is to precompile assets only in production. If you need to change it, you should do it in your own app and it can be done as @steveklabnik said and by changing config/application.rb to require assets in production.

@gkop
Contributor
gkop commented Mar 23, 2013

This isn't about assets, it's about templates.

@rafaelfranca
Member

If you need coffeescript templates you should change in your application. Not every application use coffeescript templates and we don't want to make this the Rails default.

@gkop
Contributor
gkop commented Mar 23, 2013

How about about disabling coffee templates in test and development by default?

@rafaelfranca
Member

I don't think is worth, doing this we will also disable coffeescript assets. If you need coffee templates on production just put the gem in the top level

@gkop
Contributor
gkop commented Mar 23, 2013

Fair enough, thanks guys.

@jeremy
Member
jeremy commented Mar 23, 2013

I'm +1 on this. We're bundling and encouraging coffeescript. It is the Rails default already.

And it's extra confusing that they work in dev/test, then break when you deploy.

@jeremy jeremy reopened this Mar 23, 2013
@jeremy jeremy and 1 other commented on an outdated diff Mar 23, 2013
railties/CHANGELOG.md
@@ -1,5 +1,9 @@
## Rails 4.0.0 (unreleased) ##
+* Put coffee-rails in top-level of generated Gemfile
@jeremy
jeremy Mar 23, 2013 Member

This describes what changed, but not its purpose or relevance.

Imagine you're reading this changelog to hear about new things you can do with Rails.

What does this tell you? What should it tell you?

@gkop
gkop Mar 25, 2013 Contributor

Thanks for this feedback.

@guilleiguaran
Member

I'm not sure if we still needing the :assets group in the Gemfile, I think the assets compilation isn't done 'by accident' anymore in production when a requested asset is not precompiled

@jeremy
Member
jeremy commented Mar 24, 2013

@guilleiguaran Yeah, I remove the assets group in apps now. Nice to go back to Bundler.require :default in config/application.rb instead of the strange Bundler.require :assets => ... line.

@gkop Could you update the changelog entry and rebase master? ❤️

@gkop gkop Put coffee-rails in top-level of generated Gemfile
v3 of pull request based on additional feedback from @jeremy
940da7d
@jeremy jeremy merged commit 825b91b into rails:master Mar 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment