-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Grape formatter syntax instead of monkey-patching. #6
Conversation
|
||
```ruby | ||
get "/user/:id", :rabl => "user.rabl" do | ||
@user = User.fond(params[:id]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be User.find?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, fixed.
@dblock thanks! |
Use Grape formatter syntax instead of monkey-patching.
isn't strange to assume the default formmater is the JSON formatter? instead of the user defined formatter? |
@guilherme I am not sure I understand the question, could you please elaborate? Thx. |
i've misunderstand this: formatter :json, Grape::Formatter::Rabl it means that the formatter for JSON is Grape::Formatter::Rabl, if its not possible to use it it will fallback to the default. I was thinking about it would be possible to do something: formatter :xml, Grape::Formatter::Rabl In this case the fallback would be the xml default formatter, but it doesnt make any sense. sorry for taking your time. |
This will work with the next release of Grape. We have refactored formatters in order to enable complete control of output by external libraries without having to monkey-patch Grape. This is hopefully a bit cleaner.
The updated syntax is now as follows:
The formatter implementation will fallback to Grape's JSON formatter.
See ruby-grape/grape#44 as well.