diff --git a/app/controllers/learning_objects_controller.rb b/app/controllers/learning_objects_controller.rb index a7e1efbf80ffa3feef72aece425cdd359f202625..7ec6144ff185c5060e6a2a9001f62577682b9b14 100644 --- a/app/controllers/learning_objects_controller.rb +++ b/app/controllers/learning_objects_controller.rb @@ -42,14 +42,7 @@ class LearningObjectsController < ApplicationController respond_to do |format| if publisher.create_draft @draft # go to file submission page - if @draft.type == 'Link Externo' - notice = 'Seu objeto foi criado! Para que ele seja publicado é necessário informar um link.' - path = upload_link_learning_object_path(id: @draft.id) - else - notice = 'Seu objeto foi criado! Para que ele seja publicado é necessário enviar o arquivo.' - path = upload_learning_object_path(id: @draft.id) - end - format.html { redirect_to path, notice: notice } + format.html { redirect } else format.html { redirect_to new_learning_object_path, notice: 'Não foi possÃvel criar o objeto.' } end @@ -135,11 +128,11 @@ class LearningObjectsController < ApplicationController @type = @learning_object.type else @type = case @learning_object.default_attachment.mime_type - when /image\//i then 'Imagem' - when /audio\//i then 'Ãudio' - when /video\//i then 'VÃdeo' - when 'application/pdf' then 'PDF' - end + when /image\//i then 'Imagem' + when /audio\//i then 'Ãudio' + when /video\//i then 'VÃdeo' + when 'application/pdf' then 'PDF' + end end end @@ -154,4 +147,11 @@ class LearningObjectsController < ApplicationController end end + def redirect + if @draft.type == "Link Externo" + redirect_to learning_object_path(id: @draft.id) , notice: 'Seu objeto foi criado com sucesso!' + else + redirect_to upload_learning_object_path(id: @draft.id) , notice: 'Seu objeto foi criado! Para que ele seja publicado é necessário enviar o arquivo.' + end + end end