I like how Rails has each controller in it’s own file and it’s automatically loaded and I’m trying to do the same for my Sinatra site.
I have, for example, my “Users” pages, which is users/login, users/logout and so on, what I’d like to do is seperate all these, and other pages, like news, admincp, and so on into their own files.
How would I go about having them auto loaded when my Sinatra site is started?
This is how I accomplished this with my project.
I put all the “controllers” in a directory, I then created a file named
init.rbwith the following code:Then in my main app file the following code:
Hope this helps.