Disable Asset Pipeline/Sprockets Rails 4.1

2019-01-25 03:59发布

问题:

I cannot seem to find a way to disable the Asset Pipeline in Rails 4.1. I see a lot of information for Rails 3.2.

I want to use Grunt/GulpJs and bower to handle all of my assets and I cannot seem to find something for this. Rather I find a decent amount but most of it doesn't apply to me or is broken.

There is the half-pipe gem. However half-pipe relies on Rails 4.0 and I'm on Rails 4.1 and I can't find where to force a Gem to install in different version of Rails, if that's even possible.

This question expanded into a few more questions than I intended. Basically I just need to know how to disable the Asset Pipeline, barring that how to integrate GruntJS.

回答1:

You can disable the asset pipeline in config/application.rb by adding the following line to it :

config.assets.enabled = false

You could also turn off asset pipeline while creating a new rails application by passing the --skip-sprockets option to it:

rails new myappname --skip-sprockets


回答2:

Add this to your config/application.rb:

config.assets.enabled = false

config.generators do |g|
  g.assets false
end

This will disable the asset pipeline and it will prevent the cli generator from creating assets when generating a scaffold.