Skip to content
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

respond_with should allow to render a template outside of the controller action #162

Closed
itkin opened this issue Apr 14, 2016 · 1 comment

Comments

@itkin
Copy link

itkin commented Apr 14, 2016

Hello,

I was thinking it may be cool to be able to render a template file instead of a controller action. Would play nice for specific nested resource use cases.

Since Rails allow this the change would be pretty trivial : line 203 of responder.rb

elsif has_errors? && default_action
  render :action => default_action
#by 
elsif has_errors? && default_action
  render default_action

In order to allow this kind of behavior :

respond_with @my_instance, action: '/my_other_instances/show', location: my_other_instance_path(@my_other_instance)

What do you think ?

@lucasmazza
Copy link
Contributor

I think it's an acceptable change to make the responder more flexible, but I'm not 100% sure if it would have any bad side effects in the rest of the responder logic that takes the current action in account to set the flash messages or do redirections - maybe if we introduce a new view option would help avoid these issues?

Feel free to set up a PR so we can discuss on top of the code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants