milkcocoa / grape-jbuilder Goto Github PK
View Code? Open in Web Editor NEWUse Jbuilder with Grape
License: MIT License
Use Jbuilder with Grape
License: MIT License
resource :appointments do
get nil, jbuilder: 'appointments' do
end
This is how one needs to write the routes in order for it to be the same as:
get do
end
Hi there,
Is there way to set to use layout when using in Rails? I tried applying one using the docs of https://github.com/LTe/grape-rabl but there was no success.
Take a simple template views/api/posts.jbuilder
:
json.posts do
json.array! @posts do |post|
json.partial! 'post', post: post
end
end
And a structure like this:
views/
- api/
- _post.jbuilder
- posts.jbuilder
I get the following error in my views specs:
ActionView::Template::Error:
Missing partial /_post, views/api/_post ... Searched in:
* "/path/to/app/views"
But my controller specs render everything correctly without raising the template error. Seems like an error to have the second potential lookup start with the views
namespace.
Not sure if this is grape, jbuilder, or grape-jbuilder, just assumed it was this library because it seems like you are setting up the render paths.
Or is this something I did?
When using JBuilder within Grape (via grape-jbuilder), it appears that json.cache! isn't supported.
The default file extension is .json.jbuilder
but this gem is expecting to be used .jbuilder
.
When using partials though, you have to use .json.jbuilder
.
So, your folder will look like this:
app/views/api/
├── _appointment.json.jbuilder
└── appointments.jbuilder
appointments.jbuilder:
json.link root_url
{"error":"undefined local variable or method
root_url' for #Grape::Endpoint:0x007ff5640423b8"}`
json.array! Item.all, partial: 'item', as: :item
throws exception TypeError: {:partial=>"item", :as=>:item} is not a symbol
ruby 2.1.2
rails 4.1.6
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.