Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Remove the require_tree directives from the sass and JS files. It's better design to import or require things manually.

I'm sorry, what?



Yeah, personal choice, but I've had a lot of problems with rails "require_tree" in the past. Some gems add files to your code that shouldn't be required. ActiveAdmin is an example of that (though I think they've fixed that lately). To clarify, this is not about the "require" directives, only the "require_tree"


That sounds like an issue with the gems and not using require_tree


Yeah, but IMHO it's a lot cleaner if you actually know what's included instead of having 30 files in a kind of random order in there.


You can view the files in the html script includes while in development mode. It just feels wrong to me to do this manually. I have written the infrastructure code to handle javascript minification and compression. Not having to manage a script order file is one of the best parts of the asset pipeline.


Yeah, maybe I should give the asset pipeline another try. I started the habit of including files manually when it was first launched and was quite buggy. Ryan Bates from Railscasts also seems to prefer including his assets manually, he mentioned that in some of his screencasts. I kinda stole the habit from him.

I'll give the asset pipeline another try the next time...


Personal taste I guess, I'm always happy to specify my requires manually so I have a better idea and more control over what's going on, makes things more obvious for other developers reading your code too.


You know you can require another file at the top and the asset pipeline will ensure it is loaded first right?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: