Sinatra: ActiveRecord lib/models File

giles

Posted by giles at November 13th, 2008

I've got a Sinatra app using the same Active Record DB as a much larger Rails app. I need code to handle that, and I also want to keep my Sinatra app clean.

It's kind of a cheat, and for some reason lib/controllers doesn't work, but it's a tidy way to sneak a little naughty complexity into Sinatra's one-file simplicty.

2 Comments

  1. Nicolás Sanguinetti Nicolás Sanguinetti said on November 13th, 2008

    Actually, `lib/models.rb`, or just `models.rb` is kind of the standard in Sinatra for this sort of stuff.

    If by `lib/controllers` you mean declaring sinatra’s actions in different files to organize large(ish) apps, then you need to `load “lib/controllers/awesomeness.rb”` instead of `require “lib/controllers/awesomeness”`

  2. rick rick said on November 13th, 2008

    That’s how I used merb way back in the day. I used it for an upload controller since the FUD said that rails couldn’t handle large file uploads.

    I got to a point where ensuring that various rails plugins worked were more hassle than it was worth, and gave up.

Make your voice heard

Sorry, but comments are closed for this item.