Coder Social home page Coder Social logo

Comments (3)

fabrik42 avatar fabrik42 commented on June 21, 2024

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.

fabrik42 avatar fabrik42 commented on June 21, 2024

Is there anything left to say regarding this issue?
If not, I'm closing it for now...

from acts_as_api.

fduperier avatar fduperier commented on June 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.