Comments (5)
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.
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:30Ran 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.
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.
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.
Fine with me.
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.