Comments (3)
Hi,
sorry but I can not confirm this. We have specs that cover both kinds of controllers and I also tried to reproduce it manually, but everything seems to work fine.
This is the controller I tested:
class RespondWithUsersController < ApplicationController
respond_to :json, :xml
self.responder = ActsAsApi::Responder
def index
@users = User.where("").all
meta_hash = { :page => 1, :total => 999 }
respond_with @users, :api_template => :name_only, :root => :users, :meta => meta_hash
end
end
It produces:
{
"page": 1,
"total": 999,
"users": [
{
"first_name": "Me"
},
{
"first_name": "Me2"
}
]
}
Can you provide a more specific example or even a rspec test, so I can reproduce the problem?
Best,
Chris :)
from acts_as_api.
Is there anything left to say regarding this issue?
If not, I'm closing it for now...
from acts_as_api.
Hello,
I have exactly the same issue.
When trying to add meta using respond_with, nothing appears in the body response.
However, while using render_for_api, it works successfully...
Here is the code :
class ApiController < ApplicationController
self.responder = ActsAsApi::Responder
respond_to :json, :xml
end
class Api::V1::ProjectsController < ApiController
def update
if @project.update_attributes(params[:project])
meta = { :message => "L'histoire a bien ete mise a jour", :success => true }
respond_to do |format|
format.json { render_for_api :public, :json => @project, :meta => meta, :status => :created }
format.xml { render_for_api :public, :xml => @project, :meta => meta, :status => :created }
end
# respond_with(@project, :meta => meta, :api_template => :public, :status => :created)
end
end
end
Cheers
from acts_as_api.
Related Issues (20)
- Rails 5: undefined method `as_api_response' for ActiveRecord_Associations_CollectionProxy HOT 18
- NoMethodError render_for_api with rails 5 api app HOT 7
- DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper.
- Dynamic template name in extend is not supported. HOT 1
- No options found for Remove functionality. not supporting if condition HOT 1
- InvalidURIError while deploying to heroku
- Rails 3 Responder: undefined method `list_url' HOT 1
- Ruby 2.0, Rails Mongoid, and NoMethodError (undefined method `empty?' for nil:NilClass) HOT 1
- Active Model support HOT 1
- Using class methods in api_accessible definition HOT 1
- Json with all Root nodes HOT 4
- new feature HOT 4
- respond_with not working with after_filter HOT 3
- Does not use model_name when using this without ORM HOT 3
- Parent Name under association HOT 3
- can't modify frozen Hash representing deleted AR objects HOT 1
- DateTime objects are truncating milliseconds HOT 5
- introduction: confuse links
- can i have json without root element? HOT 8
- Completely custom Json output 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 acts_as_api.