Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined method 'pathname' for #<#<Class:0x0

I updated Ruby and Rails version of my project.

Ruby 2.2.3 –> 2.5.1

Rails 4.1.8 –> 5.1.7

Now when I start the server, I get this error:

F, [2020-02-03T11:15:49.912385 #92132] FATAL -- : ActionView::Template::Error (undefined method `pathname' for #<#<Class:0x00007f8f8859d7c8>:0x00007f8f8a06a2b8>
Did you mean?  path_to_image):
F, [2020-02-03T11:15:49.913172 #92132] FATAL -- :     21: 
    22:     %title= content_for?(:title) ? yield(:title) : "Rado"
    23:     = csrf_meta_tags
    24:     = stylesheet_link_tag "application", media: 'all'

My application.css:

 *= require_tree ./lib
 *= require_directory .
 *= require_self
 *= require jquery.fileupload
 *= require jquery.fileupload-ui
 *= require select2
 *= require select2-bootstrap
 *= require switchery
 ...and some css

Error doesn't depend on the contents of application.css. I tried to delete everything in file, but error still appears.

error img

If I run rake assets:precompile, I get same error:

rake aborted!
NoMethodError: undefined method `pathname' for #<#<Class:0x00007fea873db638>:0x00007fea80715df0>
Did you mean?  path_to_image
like image 504
romnoks Avatar asked Nov 06 '22 10:11

romnoks


1 Answers

In my case, the error occurred because I had twitter-bootstrap-rails gem installed and bootstrap_and_overrides.less file was in stylesheets folder to use Less stylesheets.

So I just installed static stylesheets - rails generate bootstrap:install static

File bootstrap_and_overrides.less was renamed to *bootstrap_and_overrides.css* and replaced contents with:

/*
  *=require twitter-bootstrap-static/bootstrap
  Static version of css will use Glyphicons sprites by default
  =require twitter-bootstrap-static/sprites
*/

If you also use this gem, look at Github.

But I still can not understand why this error appeared.

like image 51
romnoks Avatar answered Nov 11 '22 04:11

romnoks