ruby - Sinatra, where to place the require statments -


i'm developing sinatra/rack app, , i've run design problem. looking around, , i'm not quite sure place bulk of require statements.

i figure go in 1 of 2 places, either main.rb after requiring sinatra itself, or go in config.ru loaded @ start of application.

i'm leaning towards main.rb what's loaded of testing applications.

thank help.

i recommend:

  • require main app file config.ru.
  • require sinatra , views gems in main app
  • create individual init.rb files each of helpers, models, , routes, , require in main app.
  • require db-related gems in models/init.rb

here's example of layout use:
using sinatra larger projects via multiple files

note loading db-related gems , setting db in models/init.rb can (from irb) load file , have full model stack available poking at.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -