Hacker News new | ask | show | jobs
by nitrogen 4372 days ago
It is very possible to organize a Sinatra project elegantly. It generally involves a combination of require_relative and Dir.glob().
2 comments

That's interesting; I tend to agree with the crowd that wishes Rails didn't do any kind of auto-loading.

But are you suggesting that you need to add a kind of basic auto-loading to Sinatra to keep things sane?

Rails autoloading "just happens". If you're doing explicitly require/require_relative, even on the results of Dir.glob(), the application explicitly specifies what will be loaded, and when. For my part I find that much cleaner.
Another way is to add a file, say init.rb, to a directory and require_relative that. It achieves the same thing, of course.