WTF is up with the Rails asset pipeline

In my last two group projects my world has been turned upside down with the pain that we like to call the rails asset pipeline.

On the surface level any rails projects ships with its own standard folders and directories which keep all your files. We call these files “assets”.

In a rails project is very likely that you will have code that you write and then code and libraries that you use from other people, either open source or commercial. Our main problem that we faced in the asset pipeline was integrating other people’s code into our app.

Libraries that you use from the internet (which you do not write yourself) are usually stored in your vendors folder. These will include any external javascript, html and stylesheet files that help you to create your app.

For my two projects on our localhost the app worked fine (for the most part) but whenever we deployed to Heroku there were all kinds of problems. It took hours to figure out and the problems were 97% of the time caused by the rails asset pipeline.

In my endless troubleshooting of rails asset pipeline issues on Heroku, one thing was etched into my brain:

When Heroku compiles your assets it compiles all of your asset files into ONE FILE

E.g. if you have 10 different javascript files, Heroku will gather and append them into each other to create one file. And if you have an error in a single one of those files it will cause the whole compiled file to break.

This will save you some time when you’re just starting out. Remember to use the console and go through each and every javascript error line by line to figure out a solution. Unlike localhost, Heroku is less forgiving about javascript errors and you will need to fix them before the apps runs correctly.

On an unrelated note here is a little app I made called Words With Jaden, inspired by:

  • Momentum Chrome extension
  • Jaden Smith
  • My group talking bad about my 80s pop/rock knowledge 😀
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s