Skip to content

Instantly share code, notes, and snippets.

@ctdk
Created June 12, 2009 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctdk/129004 to your computer and use it in GitHub Desktop.
Save ctdk/129004 to your computer and use it in GitHub Desktop.
# the part of the story controller that does the saving and such
def edit
@story = Story.get(params[:id])
@poll = @story.poll[0]
#@blogs = @story.user.blogadmins.map { |b| b.blog }
@blogs = @story.user.allowed_blogs
@taglist = params[:tags] || @story.tags.map { |t| t.tag }.join(", ")
if request.post?
if (params[:commit] == "Preview")
@story.preview_story(params)
elsif (params[:commit] == "Save")
@story.save_story(params)
elsif (params[:commit] == "Publish")
@story.publish_story(params)
# ??
@story.title = @story.storydraft.title
@story.displaystatus = 'published'
@story.draft = false
@story.time = DateTime.now
@story.save
elsif (params[:commit] == "Delete")
if(params[:delconf])
@story.delete_story
else
raise DK4Exceptions::StoryError, "Deletion not confirmed, story not deleted."
end
else
raise DK4Exceptions::StoryError, "Invalid action attempted."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment