6

我正在使用 jQuery Mobile 开发 rails 4 应用程序并使用 jquery_mobile_rails gem,这意味着我不需要安装任何 jQuery 文件。我的问题是按钮没有图标。这些显示在开发中,但不在生产中。我假设我只需要编译它们,但它们在哪里,我该怎么做?

由于我没有直接使用 jQuery Mobile 文件,因此我无法选择在它们下方存储图标。gem 在开发模式下工作,但在生产模式下不工作。我可以假设宝石内部包含按钮图标吗?如果是这样,我不明白为什么它们不能在生产模式下工作。

jquery-rails (2.3.0)
jquery_mobile_rails (1.3.0)
4

1 回答 1

2

在为每个环境预编译资产时,Rails 4 当前存在一个已知问题。

尝试设置:

config.assets.precompile=true

config/application.rb.

如果这仍然不起作用,请尝试将以下内容添加到config/application.rb

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

我无法复制您在将这些文件连接到config.assets.precompile. 你可以试试这个问题的答案吗(替换上面的行):

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
}
于 2013-06-08T13:19:09.077 回答