Using praxis inside Rails

35 views
Skip to first unread message

Marek Takáč

unread,
Sep 28, 2014, 7:44:26 AM9/28/14
to praxis-...@googlegroups.com
Hi,

I am looking for an API framework to use for building APIs in Rails applications. I come across Praxis and I really like the idea with workflow and I've figured that it should be possible to mount Praxis into the rails. I've done something similar with Sinatra applications. I've just mounted the main Sinatra app class in the Rails routes. Anyway I am little bit stuck and I cannot figure out the way how to mount a Praxis app into the Rails. Is it even possible? 

Josep Blanquer

unread,
Sep 29, 2014, 1:35:28 PM9/29/14
to Marek Takáč, praxis-...@googlegroups.com
Marek,

 What is it that you're trying to accomplish from such a framework. In other words, what are the features that you would like to use from a framework like Praxis (or Sinatra), and what are the features that you want to use from Rails? When you say Rails, do you mean ActiveRecord, ActiveSupport, etc?...or do you want to use the ActionPack view/controller/routing?...
 I'm asking this since depending on the combination you're looking for it might not be compatible to do so.
 We have people using several components of Rails (like ActiveSupport and ActiveRecord...) with Praxis without any issue. These things are completely doable. But if you want to have Rails' routing somehow with Praxis (or the other way around) that just doesn't work.
 
 So, can you elaborate a little bit about what you're looking to do?


Josep M.

On Sun, Sep 28, 2014 at 4:44 AM, Marek Takáč <takacma...@gmail.com> wrote:
Hi,

I am looking for an API framework to use for building APIs in Rails applications. I come across Praxis and I really like the idea with workflow and I've figured that it should be possible to mount Praxis into the rails. I've done something similar with Sinatra applications. I've just mounted the main Sinatra app class in the Rails routes. Anyway I am little bit stuck and I cannot figure out the way how to mount a Praxis app into the Rails. Is it even possible? 

--
You received this message because you are subscribed to the Google Groups "praxis-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to praxis-suppor...@googlegroups.com.
To post to this group, send email to praxis-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/praxis-support/3940ee09-9915-4683-a51b-0a8f2e221a1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

br...@influitive.com

unread,
Oct 15, 2014, 9:38:56 AM10/15/14
to praxis-...@googlegroups.com, takacma...@gmail.com
I'm somewhat interested in this as well. Not so much to use Rails Routing inside Praxis, but more for the MediaType / Resource definitions. We're trying to build out an API and as much as we'd like to start with a new engine (from scratch), a lot of our business logic is already resides in the main Rails app. We'd have to split this all out as a shared dependency in order to move it into the API also

It'd be nice if we could decorate our existing controllers with the Praxis resource definitions such that we could auto generate docs, and incoming params etc would be type coerced as expected, but the underlying implementation would remain as Rails.

ie If a Rails controller could implement a resource the way a Praxis controller can implement a resource.

I'd be happy to take a stab at some sort of glue mechanism to achieve this but figured I'd query here first to see if it's even a possibility.

Josep Blanquer

unread,
Oct 15, 2014, 8:27:22 PM10/15/14
to br...@influitive.com, praxis-...@googlegroups.com, Marek Takáč
Brad,

 I'm trying to imagine different ways to integrate/reuse Rails pieces into a Praxis app...and I am not sure I see exactly what you'd like to achieve. I think in general this is not an easy thing, but let's try to explore some of the scenarios you're envisioning...could you please start with an example of something you'd like to do?

For example, here's a possible scenario that you might want: 
  1. I am assuming that you're saying you have a Rails app right now, which does not expose an API, but it simply renders pages, accepts forms..etc.
  2. I suppose you want to create a new set of "routes" that expose a more "restful" API to some of the things and resources that your Rails app allows you to do through the UI?
  3. But what you'd like to do is to reuse a lot of the code that exists in the Rails app? If so, let me ask you "what" exactly:
    1. you want to reuse ActiveRecord models?
    2. you want to use business-logic that is outside the AR models? i.e. modules or companion objects?
    3. you wan to use controller logic?
    4. can the new paths/urls have a unique prefix? i.e. /api/* 
    5. do you need/care about the current UI controllers be wrapped into Praxis resource definitions?
unless #3 and #5 are true I think is might be possible to work something out. Not necessarily pretty...but...for example:
  1. You could create a brand new praxis app, and "includes" the Rails code in there. As a submodule? as a gem or set of gems...etc...
  2. This app wouldn't initialize any of the Rails routing or anything like that. The Rails code would only be there ready to be used piecemeal.
  3. You can then fully define your new Praxis API using the normal definitions/mediatypes...generate docs...yadda yadda.
  4. You can then build also Praxis controllers, which could easily reuse as little or as much of the Rails models and/or business logic as you need to.
  5. This API would be prefixed by a common path i.e., /api   (which hopefully wouldn't collide with your current Rails paths).
  6. You can stick an easy LB in front to send /api traffic to your Praxis apps, and the rest to your current Rails app.
Does that make sense? or am I off in understanding what you're trying to achieve?

Josep M.




Reply all
Reply to author
Forward
0 new messages