Custom output model on Restier - odata

I have a Restier controller that correctly returns my database content. My question is if there's a way to customize the returned model from the API.
The reason for this is that I'd like to customize the JSON returned to be directly used by a javascript application.

Related

Access data in a rails form for a separate input

I'm developing a form using simple_form_for. I want my second input to be a collection derived from the first, but I can't figure out how to access the first input without submitting the form.
Is there some way to access a previously inputted value?
I’m not aware of how to do this within RoR natively; however, this behaviour is achievable using a JavaScript tool such as AlpineJS.dev, More specifically AlpineJS x-model to link JS data to the form input.

Is there a way to automatic load control values to Orbeon Forms?

We've just recently bought and started using Orbeon.
When the user edits a form, and want to save it, he press the save button, and we defined it to send the Orbeon-style XML with all the controls values to my C# REST API. When the user wants to continue editing the form, I call the Orbeon form, and there is a trigger, what fires when page loads, and it starts a REST API call to my C# REST API, to get the control values. Now we have to define map EVERY value. Eg. ControlSurname -> ControlSurname, ControlLastname -> ControlLastname ... etc.
Is there a way, that my C# API gives back the same Orbeon-style XML (maybe some values changed due to the business logic, but not the structure), and Orbeon parses it and put all the control values to its place? (Without mapping all the 87 control?) (It works in the save methon, you dont give a mapping when save...)
You can configure Orbeon Forms to load the initial data from a service. See the section Initial data from service for more on this.
The benefit of this approach is that you won't have to do any the mapping work you were referring to, and the drawback is that you have to make sure that the structure returned by your service corresponds to what the form expects, or your form might end up with missing fields or other problems.

Different json object on every request

I'm trying to create an iOS application with Github activity feed in the table or in the collection view.
The endpoint I'm hooking at is here.
And the API Doc is here
I can create Swift native objects depend on JSON but there has been written in API doc that payload object is different based on state. There is approximately a different 40 payload object.
How can I parse this type of json? Where the object is different on every request.
Should I create 40 different objects? I think it is not a smart way to do it.

web api mvc knockout file upload with entity model

I have a web api 2 which return an entity set. In the entity set I have a property for an image url. When posting the model back using knockout I want to be able to upload a file. I have seen posts where the upload is done outside of the main post. However as the entity is database first I need to know how the post can send back the knockout view model data but also pass over the uploaded file which will then be saved to a local folder and the image url stored in the model.
Many thanks

How is the URL's request dynamic in a Ruby in Rails App?

I'm learning Rails and using 'Agile Development with Rails, Fourth Edition - Prag. Prog.'.
I understand the processing of a user's request, in RoR, to be like this:
The user's request is defined in the url, in order to communicate with the app's code
The url request is then processed by RoR - the specific Controller right for the particular request is defined, and so is the user's action
Taking as reference the defined user's action, a View template is selected to output a response to the request/action (a template that can have attributes of the selected Controller, like instance variables)
So, that's what i've understood so far - is this how the dynamic URL is created in a RoR app?
Thanks in advance! I find this complex but I'm trying to learn!
It is dynamic because it identifies the resource(s) in question with the contents of the query string identifying particular records.
So for examples a url of
www.blob.com/books/23
Is for Info about the book with an id of 23
whereas
www.blob.com/books/436
is for a different book, hence dynamic as www.blob.com/books/ was the same
In terms of MVC:
The clients browser initiates a request and says which resource and operation they want, e.g. books/23
Then the request is made to the web server and the rails app and the resources name(s) and identifier(s) are passed along. Within the rails app the first stop is actually routing to determine which controller to call and then call that controller.
The controller will be fairly generic at this point as all resources will be treated similarly, the key thing is next when the controller then requests the information from...
The model layer and the underlying database, which is when then the dynamic record ID's come into play.
The controller which made this call to the model will then prepare the view page and have it sent out from the web server back to the browser that made the request.

Resources