Comments (10)
I did some work on this
from grape.
I tried you branch, but I don't know why it didnt work. always returns { }
from grape.
Did you initialize rabl per its instructions? All my patch does is get tilt in the stack. You'll still need to do RABL.initialize! (or whatever RABL requires, I don't recall) after your bundled gems are loaded, but before you 'run' your api. Give it a shot in config.ru?
Also, because the current implementation is pretty naive, you'll need to render by local variables, as detailed in the example. :)
from grape.
Rabl need to be Rabl.register!
.
resource :me do
get do
template 'user.rabl'
{ :user => current_user }
end
end
In the same folder user.rabl
object user
attributes :_id, :display_name
Again when I go to /me
All I get { }
from grape.
Hi amrnt,
I committed some changes for some simple mistakes I made. I also made an example repository illustrating how this works after my changes.
from grape.
progress going awesome! Thanks @onethirtyfive.
But there's an issue, (I have 7 items. And I want to How to output some random, not directly related items
https://github.com/nesquena/rabl/wiki/Tips-and-tricks)
object false
child(@object) do
attributes :_id, :caption, :created_at
end
node(:pagination, :unless => @object.blank?) do
{
:next => @object.next_page,
:previous => @object.previous_page,
:total_pages => @object.total_pages,
:current_page => @object.current_page,
}
end
returns
[
{ }
{ }
{ }
{ }
{ }
{ }
{ }
]
Though, it works fine with sinatra/rails
from grape.
+1
from grape.
+1
from grape.
https://github.com/LTe/grape-rabl
from grape.
The next release of Grape has cleaner support for other formatters. I made a pull request into grape/rabl using the new syntax here: ruby-grape/grape-rabl#6.
This is what the user has to do:
formatter :json, Grape::Formatter::Rabl
Hope to see a lot more formatters our there!
from grape.
Related Issues (20)
- Param with multiple acceptable Hash Types HOT 4
- Define contract instead of params HOT 8
- undefined method `rewind' for #<Rack::Lint::Wrapper::InputWrapper w/Rack >= 3.0 HOT 4
- custom type not suppot multiple types, raise `Grape::Exceptions::ValidationErrors` HOT 1
- Route#options and Route#settings are confusing HOT 1
- Ruby 3.3 && cookiejar = ArgumentError HOT 1
- Use Rack's HeadersHash instead of {}
- endpoint method_missing vs override inspect HOT 2
- Values Validator => Proc's arity < 2 ? HOT 3
- Rails Edge requires Ruby >= 3.1
- Fix specs for Rack Edge
- Fix `params` warning method redefined
- Better tracking of gems deprecation
- Rack::Lint::Error => a header value must be a String or Array of Strings, but the value of 'content-type' is a NilClass HOT 2
- Recognize_path should account for HTTP method HOT 1
- Grape and Protecting Against Mass Assignment Abuse HOT 8
- Why do you convert PATH_INFO? Is there some RFC? HOT 2
- Add support for exclusive parameter groups (e.g. exactly_one_of) HOT 2
- Drop support rack ~> 1 ? HOT 2
- Replace Appraisals by eval_gemfile ? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grape.