Skip to content

Allow for respond_with#17

Closed
LTe wants to merge 1 commit intofabrik42:masterfrom
LTe:master
Closed

Allow for respond_with#17
LTe wants to merge 1 commit intofabrik42:masterfrom
LTe:master

Conversation

@LTe
Copy link
Copy Markdown

@LTe LTe commented May 17, 2011

You can use respond_with with Hash

respond_with :simple => :hash

@fabrik42
Copy link
Copy Markdown
Owner

Hi,

sorry but I don't understand the benefit of this pull request.
Basically everything acts_as_api does is it constructs a hash for you, that you can render as xml or json.
If you already have a hash, there is no need for acts_as_api.

@LTe
Copy link
Copy Markdown
Author

LTe commented May 17, 2011

If you set default responder in controller to ActsAsApi::Responder you cannot use respond_with with hash like in ActionController::Responder. With this feature I can send non-resourceful data as simple hash.

Of course without this patch I can basically execute in other way

respond_with [:simple => :hash]

Usecase

def where_i_should_redirect
  respond_with :redirect_to => some_dynamic_url
end

@fabrik42
Copy link
Copy Markdown
Owner

Hey,
I really appreciate your interest in acts_as_api, but I won't merge this into master.

I think providing a method as_api_response(api_template) for a class that only returns self and doesn't consider the passed param at all is misleading and not a good idea.

As I said before, there is no need to use acts_as_apiif you already have a hash ready.

Btw: Maybe you're interested in this wiki article, it explains how to use acts_as_api with any class: https://github.com/fabrik42/acts_as_api/wiki/Declaring-api-templates-for-any-class%21-%28no-orms%29

@fabrik42 fabrik42 closed this May 18, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants