This is my first post regarding this new feature of rails 3.1 and later, the assets pre-compiler.
To begin with, I believe that assets precompiler is an awesome feature of Rails no matter how quirky it looks when starting using it. Most likely, you are already convinced for that if you ‘re reading this post but I feel like I want to share with you my love to this feature.
BUT if you ever run into this error:
rake assets:precompile – Resolve the undefined method `directory?’ for nil:NilClass error message
locally or on production you will probably spend a lot of time looking around what is wrong. The –trace param will not help much as it doesn’t reply to the question: “What exactly is nil??”.
Well, I dubugged this situation by removing all the assets from my /app/assets/ folder and adding the folder by folder while re-running the rake assets:precompile task after every addition. I was getting this error continusly till I tracked down to the specific folder whose files where causing the issue.
Long story short
That folder had aliased files (symlinks). Aliases and symlinks are the nil objects that the assets precompile task cannot find and aborts the operation. So, within your /app/assets file you should not have any aliased file and you are good to go.
I hope this helps.