Permalink
Browse files

Merge pull request #46 from alphagov/artefact_admin_url

Add admin_url_for_edition method for redirecting
  • Loading branch information...
2 parents cae9baf + fdb62c8 commit 4c4eee81da164d358154808157e67c6808b668b9 @mnowster mnowster committed Dec 21, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 app/controllers/artefacts_controller.rb
@@ -20,7 +20,7 @@ def index
def show
respond_with @artefact do |format|
- format.html { redirect_to @artefact.admin_url }
+ format.html { redirect_to admin_url_for_edition(@artefact) }
end
end
@@ -34,7 +34,7 @@ def edit
def create
@artefact.save_as action_user
- location = @artefact.admin_url(params.slice(:return_to))
+ location = admin_url_for_edition(@artefact, params.slice(:return_to))
respond_with @artefact, location: location
end
@@ -84,6 +84,13 @@ def destroy
private
+ def admin_url_for_edition(artefact, options = {})
+ [
+ "#{Plek.current.find(artefact.owning_app)}/admin/publications/#{artefact.id}",
+ options.to_query
+ ].reject(&:blank?).join("?")
+ end
+
def tag_collection
@tag_collection = TagRepository.load_all(:tag_type => 'section')
.asc(:title).to_a

0 comments on commit 4c4eee8

Please sign in to comment.