Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeating Error: undefined method `start_with?' for nil:NilClass

I've gotten this weird error message that keeps me from working on my application.

undefined method `start_with?' for nil:NilClass

with line 5 highlighted in my app/views/layouts/application.html.erb file:

<%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>

The error seems to come out of nowhere. The first time I got it I had attempted to load CarrierWave. I got through ReadMe but it didn't work so I tried to back out of the installation.

When I comment out this line the app loads but with no bootstrap formatting at all. I initially focused my search with CarrierWave, deleted and re-installed the gem, but was unsuccessful and found nothing really pointing me in the right direction. I spent days on this. Finally, I reached out to a mentor who pulled my code down from github and found no errors. The app worked fine for him. I pulled down a previous, known working commit, and it worked for me as well. So, although not solved I could continue working on my app (having to re-do some work). Now, the problem has reappeared while working on my app. Not CarrierWave this time, just normal editing. Without warning the application just stopped loading but with the same start_with? error message on my app/views/layouts/application.html.erb file.

I've spent a considerable amount of time searching for answers and a permanent fix on Stackoverflow.

Solutions that seemed to work for others, but HAVE NOT worked for me are: 1. Remove //= require_tree . from application.js, and 2. Downloading and installing node.js

Some posts support the thought that the idea that the issue is local and would only show up in dev, not prod. I'm only working in dev at the moment. While there's a lot of other info, I've struggled with this for days now and feel that every possible solution gets me further down a rabbit hole that is completely foreign to me. I am a newbie...about 3 months into my knowledge on Ruby. I'm really not even sure what code to add here because I can't seem to isolate the issue. I only know that formatting seems to be affected when I comment out line 5 (as above).

Trust me when I say I've searched quite a bit. I'm very hard headed, but optimistic I can find an answer if given the time but I'm stumped here and just want to move on with learning to create with Ruby/Rails.

My gem file is below. Perhaps I'm missing something very obvious.

ruby '2.2.0'

source 'https://rubygems.org'

group :production do
  gem 'pg'
  gem 'rails_12factor'
end


gem 'font-awesome-sass'
gem 'bootstrap-sass'
gem 'simple_form'

gem 'devise'

gem 'seed_dump'

gem 'rails', '4.2.0'
group :development do
  gem 'sqlite3'
end
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
 gem 'byebug'
 gem 'web-console', '~> 2.0'
 gem 'spring'
end

Application.js

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require bootstrap-sprockets

The only other info I can provide is that I've scaffolded my resources and used devise to create my User model.

Thanks. I'm in your debt if you can help me solve this. I am new, but I want to learn.

like image 463
Phil_ish Avatar asked Mar 16 '23 05:03

Phil_ish


2 Answers

Thanks this helped me work out a bit more of whats going on. Seriously unhelpful error message.

Commenting out $icon-font-path in _variables.scss worked for me. If you have a look you will see that there is a [converter] comment that says:

If $bootstrap-sass-asset-helper if used, provide path relative to the assets load path. This is because some asset helpers, such as Sprockets, do not work with file-relative paths.

If you are not using the fonts just comment it out. If you need to use them set $bootstrap-sass-asset-helper to true and set the path as needed. That also worked for me.

like image 109
Mischa Colley Avatar answered Mar 18 '23 18:03

Mischa Colley


It seems that the order is important here, the following order - if bootstrap-sprockets is defined before bootstrap - causes this error

@import "bootstrap-sprockets";
@import "bootstrap";

while this order seems to work

@import "bootstrap";
@import "bootstrap-sprockets";
like image 22
0x4a6f4672 Avatar answered Mar 18 '23 19:03

0x4a6f4672