fabrik42/acts_as_api

Won't play nice with namespaces

Closed this issue · 7 comments

Without any sort of API versioning, I have my controllers in a V1, V2 namespace such that the controllers are V1::FooController < ApplicationController

The render_for_api method is thus not added to the controller as it cannot find them due to the namespace. I suggest adding support for namespaces and/or api versioning.

this is not the problem actually, non-namespaced controllers are not getting the method either, despite "AbstractController::Rendering.send :include, ActsAsApi::Rendering" being called

I fixed it temporarily by explicitly adding the include into the application controller. Do you have any idea why the gem include would fail?

require 'acts_as_api'
class ApplicationController < ActionController::Base
include ActsAsApi::Rendering

At the moment the including of acts_as_api is a little bit quirky.

The gem is broken since the Rails3 rc. So I think I will have to rework the include process, maybe by using the plugin methods of rails 3: http://edgeguides.rubyonrails.org/plugins.html#add-an-acts_as-method-to-active-record

If this is the only way then ok, but if we can do it gem-wise, it would give users more options.

I fixed the problem this morning.
Instead of including ActsAsApi::Rendering method into the AbstactController::Rendering I included it directly in ActionController::Base

great!

should work with the 0.2.1 gem version again! please note that you have to update your code, because you have to mention an api template now!