简体   繁体   中英

Rails 4 - Application.js contains merge conflicts, not sure how to resolve them

I have a Rails app in which my Application.js generated by sprocket somehow got merge conflicts - and I'm not sure how to remove them. In Chrome I get the the following error:

Uncaught SyntaxError: Unexpected token <<

And I can see that this is included in the file:

[...]
<<<<<<< HEAD

//= require turbolinks
//= require jquery.turbolinks
//= require chosen-jquery
=======
>>>>>>> 9e6c961b13c6c09da1cb8cdc055c799b829ff824
//= require jquery.purr
[...]

But I currently can't see any merge conflicts in my own Application.js file (not the generated one).

I have tried both rake assets:clean , rake assets:precompile and rake assets:clobber without any success.

Any ideas on how I can get rid of these errors?

Update for clarification

This is how my manual (not generated by Sprockets) application.js file looks like:

//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require chosen-jquery
//= require scaffold
//= require jquery.purr
//= require best_in_place
//= require bootstrap-datepicker
//= require jquery-fileupload
//= require autocomplete-rails
//= require jquery-ui
//= require bootstrap
//= require jquery.countdown
//= require autocomplete-rails
//= require bootstrapValidator.min

//= require turbolinks

//= require_tree .

So, no merge conflicts in this file, but rather in the file that gets generated by the sprockets gem.

Can also mention that I recently had a merge conflict in my "manual" application.js file, but the error / conflict persists for some reason in the file that was generated by sprockets - and I'm not sure how to remove it.

The merge conflicts originally solves manually. Just make sure that application.js looks good before doing git add app/assets/javascripts/application.js && git commit

I believe that your application.js file should looks like this:

[...]
//= require turbolinks
//= require jquery.turbolinks
//= require chosen-jquery
//= require jquery.purr
[...]

Deleting my local repository / folder and then cloning my remote repository made it work. Probably some caching issue. Might be a better way to get it working though, but I couldn't find any.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM