Ruby on Rails Friday, May 2, 2014

On Fri, May 2, 2014 at 5:37 AM, Paul Olivers <poliphox@gmail.com> wrote:
> Hi all,
>
> I want my app to have an HTML5 front end, and a JSON API. Would it be
> overkill to split these up into separate engines?

Yes. You don't need an engine for every front end.

What could make sense is to build the core backend of your application
as a service with an API, a la rails-api
(https://github.com/rails-api/rails-api) which would take RESTful
requests and respond with JSON. A user-facing web site (delivering
HTML5++) could be built alongside, not necessarily as an engine, but
it *could* be an engine, especially if it is doing more than the
back-end RESTful app/service is doing.

But making a separate engine just to deliver JSON seems redundant to me.

>
> So, I'd have a core Rails app (with Devise for auth), the controllers for
> the HTML and JSON front ends as 2 separate Rails engines.
> Also, would all of my models belong to the core app, or would I have ANOTHER
> engine with the models in?

If you can architect your application into separate logical services,
which have little interaction with each other, that makes a good set
of engines.

If you are just starting out with this application and it is meant for
eventual deployment (as opposed to something more of a learning
exercise) then I'd suggest you forgo the engines at this point, and
see how your app develops, and how it reacts under development and
use. On the other hand, if you really understand the application's
domain and how users interact with it, go ahead and architect out the
various services as engines.

>
> thanks,
> Paul.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/cde2f69a-e799-4f92-a478-e6612109bc42%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHUC_t-u1OMtfbhJuPHXnN%3D8TBUGVQYCQMtyyyaACDFZBm0EeA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment