0

Whenever I am pushing to production (not Heroku) I am getting

rails assets precompile phase failed

I want to add a way to force my colleagues check their css code, hence I asked them all to run

rake assets:precompile

before even comiting to a branch so that they all make sure they didn't do any CSS syntax errors. Git is always generating public/assets folder which I don't want to add to my git repository so I added the following line in my gitignore -> public/assets. Evan that, git doesn't want to ignore my files from public/assets. Is there a way to ignore files generated into this folder? Do they have another path after being generated?

Vlad Balanescu
  • 664
  • 5
  • 27
  • Possible duplicate of [Stop tracking and ignore changes to a file in Git](http://stackoverflow.com/questions/936249/stop-tracking-and-ignore-changes-to-a-file-in-git) – Brad Werth Oct 17 '16 at 17:03
  • Thanks for your comments. Tried those commands and didn't work for me. I guess the route is not public/assets actually – Vlad Balanescu Oct 17 '16 at 17:04

2 Answers2

2

git doesn't want to ignore my files from public/assets

This is happening because you / your team members have already committed public/assets to the repo. This answer outlines the basic commands you need to run to remove the unwanted files / folders from you repo

  1. Commit all you current changes
  2. run git rm -r --cached . to remeove changed files
  3. then run git add -A and git commit -m 'fixes .gitignore' like you normally would

I want to add a way to force my colleagues check their css code

You can also automate this using a build-monitoring system from one of the continuous-integration tools (e.g. CirclCI). Each time your team pushes anything to a repo, CI client can run scss-lint on your app's app/assets/stylesheets directory, and rake assets:precompile to make sure the new code base does not 'break' any parts of you app.

More about Continuous Integration for Rails from CirclCi: https://circleci.com/docs/language-ruby-on-rails/

Community
  • 1
  • 1
dimitry_n
  • 2,939
  • 1
  • 30
  • 53
0

ANSWER: RAILS_ENV=production rake assets:precompile line can be added to .travis.yml, Travis CI configuration file of the project, and whenever pushing to Github, Travis will do the hard work for you! The build will fail if this command is failing!

Vlad Balanescu
  • 664
  • 5
  • 27