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

Not redirecting to show page after successful create / update #6

Open
lucaspiller opened this issue Feb 26, 2010 · 3 comments
Open

Comments

@lucaspiller
Copy link

This could very well be me just not reading the docs fully, but I have spend quite a while and can't find anything.

I have a resource that doesn't require a show page (at least for HTML - which is all I care about at the moment), as such, after a create and update I want to redirect back to the parent object's show page.

I have tried adding the following, however even if the action is not successful they are still redirected. Is there anyway around this?

response_for :create, :update do
  redirect_to campaign_path(parent_object.id)
end
@look
Copy link

look commented Feb 26, 2010

If you action is not successful and you don't want to render the new/edit page again, you should use response_for :create_failed and handle it there.

For successful actions, what you have should work (I do it all the time).

@lucaspiller
Copy link
Author

Thanks, that does the trick, but it isn't particularly elegant:

response_for :create, :update do
  redirect_to campaign_path(parent_object.id)
end

response_for :create_fail do
  render :action => :new
end

response_for :update_fail do
  render :action => :edit
end

It would be great if there was a :create_success action!

@look
Copy link

look commented Mar 1, 2010

There is, it's called :create.

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

No branches or pull requests

2 participants