Reputation: 895
I'm looking write a webservice. A simple example of how a user will interact with this service is user-signup. A user can hit the service to create an account (if they're mobile). On the other hand, users can login (from a mobile app) to the application using the service. Now this service is for an existing rails application. My plan is to build a sinatra app within this rails app, and mount as a rails engine: this app will interact with my existing rails models to produce/consume the appropriate json. Would this be a good approach? Have anyone tried this before? Thank you.
Upvotes: 1
Views: 1697
Reputation: 1238
I think you should just get rid of Rails and just forget about it. Just use Sinatra for your app, and just pure Rack whenever you can for your middleware.
Contrary to popular belief, you can easily build large-scale applications with Sinatra, the internals can be organized in any way you want.
Rails is slow. Why not just run something fast for everything? There is absolutely nothing you can't do with Sinatra and pure Rack, it's incredibly flexible.
Upvotes: 0
Reputation: 1832
"Premature optimization is the root of all evil."
Only go the Sinatra route if you need speed. For example, your rails app might do a lot of unnecessary computation in the application controller which you want to bypass in a mobile app. Even so, I'd be really sure it eats into response time on the mobile client before I started down the Sinatra path. Shaving off 10 milliseconds in the response time probably isn't worth all the developer time unless you're developing a game or something else which is highly interactive.
Since you've got an existing Rails app, just use Rails. It already has most of the code you need. You just need to write some JSON views. That's a lot simpler and easier to maintain than a parallel Rails/Sinatra stack.
Upvotes: 2