All threads / rails 4.2.8 - stylesheet_link_tag throws ActionView::Template::Error: no implicit conversion of nil into String

Ask A Question

Notifications

You’re not receiving notifications from this thread.

rails 4.2.8 - stylesheet_link_tag throws ActionView::Template::Error: no implicit conversion of nil into String

Widu Wittekindt asked in Rails

I'm trying to update a rails app which runs totally fine if I use rails 4.2.4 (the version it's been developed on) upto rails 4.2.7

As soon as I switch to rails 4.2.8 or later (tested all versions upto 4.2.11) I get

Failure/Error: = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true

ActionView::Template::Error:
  no implicit conversion of nil into String
  # ..../actionview-4.2.11/lib/action_view/helpers/asset_url_helper.rb:140:in `join'
  # ..../actionview-4.2.11/lib/action_view/helpers/asset_url_helper.rb:140:in `asset_path'

Having a loot at the actionview-4.2.11/lib/action_view/helpers/asset_url_helper, I can see that the error happens in

File.join(relative_url_root, source)

where

pry(#<#<Class:0x00000009a9aa98>>)> source
=> "/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css"

pry(#<#<Class:0x00000009a9aa98>>)> relative_url_root
=> {}

As soon as I remove all stylesheet_link_tags and javascript_include_tags, the error does not show up anymore (but of course all my styles and javascripts are gone).

Here's the relevant part of my app/views/layouts/application.html.haml

!!!
%html
  %head
    %meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"}
    %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}
    %title BrotUndButter
    = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
    = javascript_include_tag 'application', 'data-turbolinks-track' => true

Any ideas?

I've searched the net for hours, but could not find anything helpful.
and this https://stackoverflow.com/questions/16044008/no-implicit-conversion-of-nil-into-string
does not help at all. This bug should not affect rails 4.X.Y at all. Anyway I tried to set
config.relative_url_root = ""
in my application.rb but that did not make a difference.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 33,399+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.