views:

413

answers:

2

For my next web application, I'm debating whether to use Rails 3.x or Sinatra.

I would like to use the server to provide user authentication, application-triggered emails, a fairly complex data model (behind ActiveRecord), and a JSON data interface with the web client. The client side will use static HTML, static CSS, Javascript/jQuery to render the JSON data into the views. The "policy" for rendering views will be driven by the Javascript code and some of the JSON data. I do not plan to use any dynamic view technologies such as ERB, HAML, or RJS.

Would I be better off with Sinatra or Rails 3.x?

Are there any other questions I should ask before making that decision?

A: 

You might want to take a look through the other lightweight Ruby frameworks before you decide - the post is a little old, but probably worth a scan.

Dave Everitt
+2  A: 

Hi,

Your data model is fairly complex, so I imagine your application will have to handle a significant number of business rules and many of interaction possibilities.

Sinatra is meant for handling lightweight software architectures. If you choose Sinatra you'll probably encounter design and organization issues you'll have to handle by yourself. Rails implements the MVC pattern and can help you organize your code by offering a lot of useful mechanisms.

You still can build a "full-stack" web app with Sinatra but you'll have to do a lot by yourself especially if the number of functionality you'll provide is high (or will grown). I think Rails fits naturally better in larger architectures.

PS : ActiveRecord is available both in Sinatra and Rails.

Antoine
@Antoine - Given that I would use ActiveRecord in either case, why does it make a difference? After all doesn't ActiveRecord let you put business rules in the model layer? What would Rails' full MVC stack give you for business rules that Sinatra does not have?
Jay Godse
For example, you usually need validation rules in your model layer (not provided by AR).But the point is more general : in Rails you put yourself in a existing structure. You follow conventions and patterns which ensure your app will be easily maintainable and will scale well.Sinatra only helps you in routing and dispatching. In an large-size app you'll need more than this : you'll need separation of concerns and structuring patterns. Of course you can write a framework over Sinatra to ensure this but it takes time and will have bugs (like in every program).(You can also use Padrino)
Antoine