Commit 2aeb10413dfa9738d353bd18d99d8378602c1051
1 parent
3971931c
Exists in
staging
and in
42 other branches
Changing redirect after destroy to referer or article parent
Showing
1 changed file
with
8 additions
and
1 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -182,7 +182,14 @@ class CmsController < MyProfileController | @@ -182,7 +182,14 @@ class CmsController < MyProfileController | ||
182 | if request.post? | 182 | if request.post? |
183 | @article.destroy | 183 | @article.destroy |
184 | session[:notice] = _("\"#{@article.name}\" was removed.") | 184 | session[:notice] = _("\"#{@article.name}\" was removed.") |
185 | - redirect_to :action => (@article.parent ? 'view' : 'index'), :id => @article.parent | 185 | + referer = ActionController::Routing::Routes.recognize_path URI.parse(request.referer).path |
186 | + if referer and referer[:controller] == 'cms' | ||
187 | + redirect_to referer | ||
188 | + elsif @article.parent | ||
189 | + redirect_to @article.parent.url | ||
190 | + else | ||
191 | + redirect_to profile.url | ||
192 | + end | ||
186 | end | 193 | end |
187 | end | 194 | end |
188 | 195 |