Coder Social home page Coder Social logo

Comments (5)

mepatterson avatar mepatterson commented on June 17, 2024

FOLLOWUP:

I did get this to work, albeit a bit hacky:

class Api::V1::ApiController < ActionController::Metal
  include AbstractController::Logger
  include ActionController::UrlFor
  include ActionController::Testing
  include Rails.application.routes.url_helpers
  include ActionController::Rendering
  include ActionController::Renderers::All
  include ActionController::MimeResponds
  include ActsAsApi::Rendering

  self.responder = ActsAsApi::Responder
  respond_to :json, :xml

  private

  def default_render; render; end
end

... would be nice if there was a simpler way to tell acts_as_api that it's being used in a metal controller.

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 17, 2024

I didn't try it yet, but I'll take a look into it if I find some time :)


mepatterson
mailto:[email protected]
28. Juni 2011 00:30

Ran up against a number of issues while trying to integrate
acts_as_api into a metal controller.

top of the class looks like this so far:

class Api::V1::UsersController < ActionController::Metal
include AbstractController::Logger
include ActionController::UrlFor
include ActionController::Testing
include Rails.application.routes.url_helpers
include ActionController::Rendering
include ActionController::Renderers::All
include ActionController::MimeResponds

self.responder = ActsAsApi::Responder

... but i get problems with missing a 'default_render' method, among
other things. Any idea how to get this to work with metal? I don't
want all the other stuff that comes along with my app's
ApplicationController and I want it to be super-fast...

from acts_as_api.

nicholasmott avatar nicholasmott commented on June 17, 2024

Just an update in case this will help someone else - I recently added acts_as_api to a metal controller. The following was the minimum to make it work successfully.

class Api::V1::BaseController < ActionController::Metal
  include ActionController::Rendering
  include ActionController::Renderers::All
  include ActionController::MimeResponds
  include ActsAsApi::Rendering

  self.responder = ActsAsApi::Responder
  respond_to :json

end

Updates to either Rails or acts_as_api have removed the need for the default_render call. It's now no harder to add than to a standard controller.

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 17, 2024

Cool. So I guess I can close this issue now.

Do you mind, if I put you comment in a Wiki article (pointing to you and this issue)?

from acts_as_api.

nicholasmott avatar nicholasmott commented on June 17, 2024

Fine with me.

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.