[Rails] Re: Better way to write this piece of code

2016-02-18 Thread Roy Royal
> While I can applaud the desire, I think in this case you should NOT > attempt to simplify that in any way, as it would obfuscate what's going > on. This is clean, terse, and extremely clear what is going on. > > If this sort of thing is repeated over and over with different status > codes, *that*

[Rails] Better way to write this piece of code

2016-02-17 Thread Roy Royal
I use this type of code for different message and status in my api. def 404 respond_to do |format| format.json {render json: { error: '404, not found' }, status: 404} format.xml {render xml: { error: '404, not found' }, status: 404} end end This works but can I refactoring this code,

[Rails] Re: Building xml/json api

2016-02-15 Thread Roy Royal
Colin Law wrote in post #1181373: > On 12 February 2016 at 23:37, Roy Royal wrote: >> The requirements for my api is. >> * at least json but preferably also xml >> * sort resources on dates >> * search for a resource in a http request >> * get resources belong

[Rails] Building xml/json api

2016-02-12 Thread Roy Royal
Hi! I'm building my first API with rails and i hope someone can point me in the right direction. What I want to know is which tutorials I should watch/read and also which gems/framework I should use. All tips will be helpful The API should follow RESTful and HATEOAS (don't have to be strictly) Th