Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In a Rails 4 app, how do I compile the jQuery Mobile button icons?

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)
like image 824
markhorrocks Avatar asked Jun 06 '13 08:06

markhorrocks


1 Answers

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
}
like image 171
mccannf Avatar answered Oct 06 '22 01:10

mccannf