}
format.api { render_api_head :conflict }
end
- rescue ActiveRecord::RecordNotSaved
- respond_to do |format|
- format.html { render :action => 'edit' }
- format.api { render_validation_errors(@content) }
- end
end
# rename a page
end
# Saves the page and its content if text was changed
+ # Return true if the page was saved
def save_with_content(content)
ret = nil
transaction do
ret = save
if content.text_changed?
- self.content = content
- ret = ret && content.changed?
+ begin
+ self.content = content
+ ret = ret && content.changed?
+ rescue ActiveRecord::RecordNotSaved
+ ret = false
+ end
end
raise ActiveRecord::Rollback unless ret
end