6

I am developing a rails 4 app with jQuery Mobile and using the jquery_mobile_rails gem which means I don't need to install any of the jQuery files. My problem is that there are no icons for the buttons. These are displayed in development but not in production. I assume that I just need to compile them but where are they and how can I do that?

Since I am not using jQuery Mobile files directly, I don't have the option to to store the icons below them. The gem works in development mode but not in production mode. Can I assume that the gems contain the button icons internally? If so, I am at a loss to understand why they don't work in production mode.

jquery-rails (2.3.0)
jquery_mobile_rails (1.3.0)
markhorrocks
  • 1,199
  • 19
  • 82
  • 151

1 Answers1

2

There is a known issue currently with Rails 4 when precompiling assets per environment.

Try setting:

config.assets.precompile=true

in config/application.rb.

If that still doesn't work, try adding the following to config/application.rb:

config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)

I can't replicate the strange error you get when concatenating these files to config.assets.precompile. Can you try the answer to this question instead (replace the line above):

config.assets.precompile << Proc.new { |path|
  if path =~ /\.(css|js|png|jpg|jpeg|gif)\z/
    full_path = Rails.application.assets.resolve(path).to_path
    app_assets_path = Rails.root.join('app', 'assets').to_path
    vendor_assets_path = Rails.root.join('vendor', 'assets').to_path

    if ((full_path.starts_with? app_assets_path) || (full_path.starts_with? vendor_assets_path)) && (!path.starts_with? '_')
      puts "\t" + full_path.slice(Rails.root.to_path.size..-1)
      true
    else
      false
    end
  else
    false
  end
}
Community
  • 1
  • 1
mccannf
  • 16,619
  • 3
  • 51
  • 63
  • Do you mean production.rb? In either or both cases? – markhorrocks Jun 08 '13 at 15:00
  • No, the bug means these changes to production.rb do not work, so you have to put them, for the moment, into `config/application.rb`. Until this issue gets fixed. – mccannf Jun 08 '13 at 15:38
  • These 2 lines in application.rb produce ': undefined method `+' for true:TrueClass (NoMethodError) The first line is Ok but not yet tested in production. – markhorrocks Jun 09 '13 at 03:59
  • config.assets.precompile=true by itself does not work. As stated above the second suggested line produced an error – markhorrocks Jun 09 '13 at 18:16
  • Never seen that error before. And if you add the second statement to production.rb does it work? Not sure it will. – mccannf Jun 09 '13 at 21:57
  • No error in production.rb in development. for some reason I get an error either way if i start Webrick in producton mode locally. – markhorrocks Jun 10 '13 at 04:11
  • I get an error undefined method `+' for true:TrueClass on config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif application-print.css) – markhorrocks Jun 17 '13 at 09:54
  • Added something else to try. Not sure why you are getting this error. – mccannf Jun 17 '13 at 12:24
  • It works fine after I remove config.assets.precompile=true. The precompile string worked perfectly. Thanks! – markhorrocks Jun 17 '13 at 13:57