All Questions
146
questions
0
votes
0
answers
119
views
Use jBuilder template to make a Hash
Is there a way to get jBuilder to generate a Hash from a template instead of a string?
render(template: "foo", formats: :json) will return stringified JSON.
I can of course parse the ...
0
votes
1
answer
123
views
How can I change an array into an object in jbuilder when it is the value of a key?
I'm using rails and I'm formatting the response with jbuilder and associations. Here is the code that I have
json.comments @post.comments.each do |comment|
json.set! comment.id do
json....
2
votes
2
answers
846
views
Rails not able to find partial
I have a folder structure like
project/app/views/api/users/_user.json.jbuilder
The error is
Searched in:
* "/Users/name/Desktop/etc/etc/project/app/views"
ActionView::MissingTemplate - ...
1
vote
1
answer
217
views
Adding an attribute to json from joined table
I am trying to provide a json that would contain information coming from two tables:MenuItem, and Partner.
In the json below "partner_number" would actually come from the partner table.
{
...
0
votes
0
answers
62
views
Navigating jbuilder to attatch html string
I am setting up a collection of ruby issues (@issues) into arrays using jbuilder so they plug into datatables. Normally with datatables each row represents a single record and you determine the ...
1
vote
1
answer
302
views
Rails returns HTML, even with `application/json` set and `.json` added to resource
Attempting to render JSON via Jbuilder when an XHR request is sent to Rails, and HTML when a normal request is sent. But every request still returns HTML.
Without JBuilder
PostController has a show ...
0
votes
1
answer
344
views
Need to create a json string from Jbuilder in rails Helper
I need to create a complex json from my Rails helper
I tried to use Jbuilder for that.
I tried a code from a xxxx.json.jbuilder and it is working great.
json.array! @demandes.includes(....) do |...
1
vote
1
answer
1k
views
How can I change the name of a key using jbuilder
I have an index.json.jbuilder which looks like this:
json.results do |result|
json.array! @artists do |artist|
json.extract! artist, :id, :name
end
end
This produces the follow JSON ...
1
vote
1
answer
889
views
How to generate a custom json response with Jbuilder & Rails
In my Ruby on Rails app, bike rental companies can manage all their bikes (reservations, payments etc.).
Context
I would like to offer a bike rental companies (shops) the option to implement a ...
0
votes
1
answer
187
views
Rails define custom json structure
I'm attempting to structure a json response to mimic an existing structure we have elsewhere in our application (using jbuilder templates). In this specific use case, we are unable to use the jbuilder ...
0
votes
1
answer
368
views
How to format jbuilder value
I got a jbuilder response like below
{
"name": "amb_devcernerpowerchart_com:patient_val2",
"value": "{\"value\"=>\"patient_value\", \"expiration\"=>31536000, \"created_datetime\"=>\"2019-...
3
votes
2
answers
2k
views
Rails 6, standalone Jbuilder in a service : partials not loading
I thought I could use Jbuilder outside of Rails controllers. The documentation said so.
I wrote this module, to include into a service object. Which is integrated in a Rails 6 api app, but is not ...
1
vote
1
answer
2k
views
Jbuilder include All Attributes and Associations
I'm trying to set up a JSON object that I can make a clone of, so I need Jbuilder to list all object attributes and associations. I've done plenty of pick and choose JSON structures using Jbuilder, ...
0
votes
1
answer
1k
views
Rails render index (JSON) after update returning empty array
In my small Rails app, I want to update an object through json format, and on success receive the index.json.jbuilder content (using the render :index on JSON format in update). But for some reason, I ...
1
vote
1
answer
2k
views
Why is Rails not finding my jbuilder template or not rendering it?
I have a route that looks like this:
resources :property_searches, :path => 'search'
That generates these routes:
property_searches GET /search(.:format) ...