Venkat
Venkat

Reputation: 35

How uncommenting jquery results in working of rails server?

I created a new rails controller $ bin/rails generate controller welcome index Modified my View

Hello, Rails!

when I restarted my rails server, I faced the below issue.

Sprockets::FileNotFound in Welcome#index
Showing /home/venkata/Downloads/app/app/views/layouts/application.html.erb where line #5 raised:
couldn't find file 'jquery' with type 'application/javascript'
Checked in these paths: 
  /home/venkata/Downloads/app/app/assets/images
  /home/venkata/Downloads/app/app/assets/javascripts
  /home/venkata/Downloads/app/app/assets/stylesheets
  /home/venkata/Downloads/app/vendor/assets/javascripts
  /home/venkata/Downloads/app/vendor/assets/stylesheets
Extracted source (around line #13):
11
12
13
14
15
16
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
Rails.root: /home/venkata/Downloads/app

Now when I uncomment the =require jquery in app/assets/javascripts and restarted the server, got the expected output. wondering How this happens by uncommenting that particular line?

Upvotes: 1

Views: 179

Answers (1)

Rajdeep Singh
Rajdeep Singh

Reputation: 17834

// is a comment but //= is not, //= require jquery includes the jquery library.

More info here - https://guides.rubyonrails.org/asset_pipeline.html#search-paths

Upvotes: 1

Related Questions