-
-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
passing serialization options #46
Comments
There is no way to pass serialization options, but you don't need to overwrite your whole action, just the required pieces. And if you have always to pass the same options, you should also consider overwriting your models or creating your own responder. |
It's not always the same options, the options depend on parameters passed in by the user. I'm assuming that by overwriting "the required pieces" you mean like this:
Is that correct? It kind of sucks to have to repeat myself in all my controllers that way; perhaps a responder is a better choice... The stuff under legacy hurts my brain :-). Do I need to create an ActionController::Responder or an ActionController::MimeResponds::Responder? |
If you need to add the same line in all controllers, you can put the logic in a module and include the module in your controllers: module ToXmlParameters
end And include this module in your controllers. If you want to go the responders road, I would suggest you to inherit from InheritedResources::Responder and add the logic you want. The ActionController::Responder is the one what you should look to know what to overwrite though. When you are done, do: InheritedResources::Base.responder = YourResponder |
Thanks for your help. I think the responder route is going to work well for me |
I too am finding that I am doing--or am about to do--the following in many controllers.
mrroach, how did your Respondor solution work out? Care to share a snippet? Jose, these seems a fairly typical scenario. Would you accept a patch to do something about this in inherited_resources itself? |
The customization does not belong to Inherited Resources. It should be at the Responders level. Take a look at responders documentation and blog posts available. :) |
Jose, I have attempted this at https://github.com/jpshackelford/resource_inclusion . I'll be interested in your feedback. John-Mason |
Is there any way to pass options to to_xml? I have many situations where I need to pass things like :root, :include, or :methods and the only way I have figured out is to override the whole action. Is there another way?
for example, in my app I have a base controller which defines a to_xml_parameters method which I always want to pass to to_xml. It seems redundant to put that in all controllers.
Thanks.
The text was updated successfully, but these errors were encountered: