13

Why is it that I often see gem 'jquery-rails outside of the :assets group?

group :assets do
  gem 'sass-rails', " ~> 3.1.0"
  gem 'coffee-rails', " ~> 3.1.0"
  gem 'uglifier'
end

gem 'jquery-rails'

Will there be buggy behavior if I put it inside?

Thanks!

mazlix
  • 6,003
  • 6
  • 33
  • 45
  • HIya, you can figure this out read here: http://guides.rubyonrails.org/asset_pipeline.html ; why the asset group is there. Hope this helps – Tats_innit May 24 '12 at 03:27

2 Answers2

13

The jquery-rails gem provides some test helpers also. So perhaps for that reason people prefer to put it outside the :assets group.

However, the :assets group is included in development and testing environment, so you should be perfectly safe to place jquery-rails in your :assets group if you like.

Just make sure you precompile your assets before you deploy your application.

thomasfedb
  • 5,990
  • 2
  • 37
  • 65
  • 2
    - 1 . If you have ever used `jquery-rails` in `:assets` group you would know that it is `NOT` perfectly safe to put into `:assets` group. From time to time, jquery-rails can break down, and no precompiling will help. Putting it outside the `:assets` would do the work. – Aleks Jun 14 '13 at 09:44
  • @Aleks as long as you precompile you assets in the right environment you should be fine. Precompiling in the production environment, as mentioned, would not work. – thomasfedb Jun 14 '13 at 14:59
  • @Aleks Note that I say that the assets group is included in development and testing, I do **not** say that it is included in production. I also said to precompile assets **before** deployment. – thomasfedb Feb 17 '14 at 00:02
4

The real answer for this is that gem 'jquery-rails' can often break up on the production, and there would be no standard way of fixing this other then initializing the gem itself from the beginning. I have seen this problems on heroku.

The fix for that is to put jquery-rails outside :assets group, and that way you would be sure that it will not break up.

Even the question is an old one, I wanted to make sure that that is the reason, and you would probably need to put 'jquery-rails' OUTSIDE :assets group.

Aleks
  • 4,866
  • 3
  • 38
  • 69