Skip to content
This repository has been archived by the owner on Oct 12, 2018. It is now read-only.

Commit

Permalink
Merge pull request #46 from alphagov/artefact_admin_url
Browse files Browse the repository at this point in the history
Add admin_url_for_edition method for redirecting
  • Loading branch information
mnowster committed Dec 21, 2012
2 parents cae9baf + fdb62c8 commit 4c4eee8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/controllers/artefacts_controller.rb
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4c4eee8

Please sign in to comment.