5 ms·
Do your Sinatra apps have access to the Rails models?
by tabbyjabby 15y ago
Do your Sinatra apps have access to the Rails models?
- deleted 15y ago[deleted]
- baghali 15y agoI don't know what github is doing about their models, but I have fairly easy solution of my own: I always symlink models in my projects. We have 2 large Rails projects and an API server using Goliath[1], one of the Rails projects and the goliath server use models with symlinks. [1] Goliath: http://postrank-labs.github.com/goliath/ http://postrank-labs.github.com/goliath/
- bretthopper 15y agoWhy not package them as a gem?
- baghali 15y agoWe are still doing massive development, once our codebase is stable enough we will move them into small gems, right now it's just a bit of hassle running bundle update for every small increment.
- heimidal 15y agoYou can plan this migration ahead of time by moving your models into gems stored in, say, vendor/future_gems/. Then just reference each gem in bundler as: gem "my_models", path: "vendor/future_gems/my_models/" Once you are able to break them out completely, just remove the path reference and use a gem server instead.
- technoweenie 15y agoYup, they're all mounted in the same ruby process.
- dana_janssen 15y agoAre you able to provide more detail on how something like this would be set up?
- tptacek 15y agoRails 3.0 just does this; given a FooApp Sinatra object, yo can match "/foo" :to => FooApp.
- michaelfairley 15y agoAlso doable without rails: # In config.ru # App, V0, and Resque::Server are each sinatra apps run Rack::URLMap.new({ "/" => App.new, "/v0" => V0.new, "/resque" => Resque::Server.new, })
- heimidal 15y agoAny app built on Rack (which includes Rails, Sinatra, and many other Ruby frameworks) can be mounted this way. See http://guides.rubyonrails.org/routing.html#routing-to-rack-applications http://guides.rubyonrails.org/routing.html#routing-to-rack-a...
- technoweenie 15y agoWe use Unicorn, which provides a Rack handler for Rails 2.2 apps. I just mounted the an API router app before the Rails handler in our config.ru. The API router app is just a big regex that looks for API related urls, or passes through to Rails. Though, jnunemaker recently showed me a trick where you can mount Sinatra apps in other Sinatra apps through `#use` (like any Middleware). I may try that out and get away from my ghetto regex routes. We recently upgraded to Rails 2.3 which is built on Rack. `ActionController::Dispatcher.new` is the last Rack app on the stack now.