简体   繁体   English

在Rails 4应用程序中,如何编译jQuery Mobile按钮图标?

[英]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. 我正在使用jQuery Mobile开发一个Rails 4应用程序并使用jquery_mobile_rails gem,这意味着我不需要安装任何jQuery文件。 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. 由于我不是直接使用jQuery Mobile文件,因此无法选择将图标存储在文件下方。 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)

There is a known issue currently with Rails 4 when precompiling assets per environment. 在每个环境中预编译资产时,Rails 4当前存在一个已知问题

Try setting: 尝试设置:

config.assets.precompile=true

in config/application.rb . config/application.rb

If that still doesn't work, try adding the following to config/application.rb : 如果仍然无法解决问题,请尝试将以下内容添加到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 . 我无法复制将这些文件连接到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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM