Bootstrap-Sass: Glyphicons showing as rectangles on production - ruby-on-rails

See the top right "admin" icon on http://base.sirius.uberspace.de/en.
When setting
config.assets.compile = true
they're showing correctly, but I guess that's not the perfect solution, is it?
Setting
config.assets.precompile += %w( '.woff', '.eot', '.svg', '.ttf' )
doesn't change anything; my mina deployment also does a precompile, as suggested:
invoke :'rails:assets_precompile'
So how could this be solved?
I'm using Rails 4.1.

Related

How to disable Bullet in ActionMailer previews

I would like to disable the Bullet gem when previewing emails using ActionMailer::Preview. In the Bullet readme, there is an instructon on how do to this for a controller, but how do I apply this to my ActionMailer previews? In my app, the previews are configured to appear at
config.action_mailer.preview_path = "#{Rails.root}/mailers_previews/"
As a workaround, I have added the following to my config/environments/development.rb
config.after_initialize do
Bullet.enable = false
pp 'Bullet Disabled' unless Bullet.enable?
... other settings ...
end
The warning is so I do not forget to set Bullet.enable = true when I have finished working on my action mailer previews. You need to restart the server to enable/disable Bullet.

rails 4.1 add videos folder to asset pipeline

Here are my paths so far:
assets
>fonts
>images
>stylesheets
>javascripts
>videos
I would like to bucket videos under the videos folder, but I can not seem to get them to be show up. My current assets.rb initializer looks like:
Rails.application.config.assets.precompile += %w( layout-home.css layout-error.css layout-static-page.css layout-brand.css )
Rails.application.config.assets.precompile += %w( layout-home.js layout-static-page.js layout-brand.js )
Rails.application.config.assets.precompile += [ Dir.glob("#{Rails.root}/app/assets/videos/**/") ]
Any ideas on how to adjust this? No matter how I adjust that last line, I can not get them to pull in.
Add the following to config/initializers/assets.rb
Rails.application.config.assets.paths << "#{Rails.root}/app/assets/videos"
Do not forget to restart the server after changing an initializer.

Rails: don't uglify HTML and CSS in test environment (using SLIM and Sass/Compass)?

I'm actively validating the HTML and CSS in request specs. Sadly, the error messages are very long because the HTML and CSS is uglified/compressed in test env.
I tried to remove the uglifier gem from the Gemfile, but this didn't work out. Do I miss some configuration option here? I can't find any for test.rb...
Update
I found that setting Slim::Engine.set_default_options pretty: true solved the problem for the HTML output.
The CSS is still compressed on one line though, I tried stuff like adding output_style = :nested to config/compass.css, setting Sass::Plugin.options[:style] = :expanded (raised an exception), add config.sass.output_style = :nested to test.rb, and setting # config.assets.css_compressor = nil also in test.rb. Didn't solve my problem.
Try setting this in test.rb:
config.assets.debug = true
In case you're using SLIM templating engine, set pretty: true:
Slim::Engine.set_default_options pretty: true
For more info see https://github.com/slim-template/slim#default-options.

Rails asset pipeline Rails.application.assets.instance_variable_get('#environment') returns nil

I am trying to compile javascript dynamically and then adding it to the sprockets store so it is available. Everywhere I researched suggested the below code to register the javascript:
env = Rails.application.assets.is_a?(Sprockets::Index) ? Rails.application.assets.instance_variable_get('#environment') : Rails.application
Rails.application.config.assets.digests[file_name] = env[file_name].digest_path
in production, Rails.application.assets.instance_variable_get('#environment') always returns nil, is there something I am doing wrong? or should I be adding something else?
Rails.application.assets itself is an instance of Sprockets::Environment
#environment' is a variable of assets_manifest, that belongs to Rails.application, like this:
Rails.application.instance_variable_get('#assets_manifest').instance_variable_get('#environment')
I got similar problems with RAILS 3.2.15,
but it was Rails.application.assets returns nil
quiet_assets.rb:4:in': undefined method logger=' for nil:NilClass (NoMethodError)
the issued line was
Rails.application.assets.logger = Logger.new('logger.log')
I back to Rails console, and find Rails.application.assets just returned nil.
I fix this issue by this step:
include two gem in your Gemfile in case you don't have it.
gem 'sprockets'
gem 'sprockets-rails'
find the file cause the issue , and initial your assets object.
you can also put that in application.rb , in my case I put it in config/initializers/quiet_assets.rb , before I refer to logger.
add this line:
Rails.application.assets = Sprockets::Environment.new
before this issued line:
Rails.application.assets.logger = Logger.new('logger.log')
in application.rb , remember have activate assets pipeline .
config.assets.enabled = true
for production you may need to set config.assets.compile = true
hope this helps somehow
Build it yourself (which is needed for new versions)
env = Sprockets::Railtie.build_environment(Rails.application)

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)
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
}

Resources