From 2fdec2b4ca8bdd3200082e03a2be1f01866ea718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20de=20Villamil?= Date: Thu, 15 Aug 2013 15:56:09 +0200 Subject: [PATCH] Removes a debug, fixes a bug when a status fails to be created --- app/controllers/admin/statuses_controller.rb | 7 ++++++- app/models/status.rb | 5 ++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/statuses_controller.rb b/app/controllers/admin/statuses_controller.rb index 6dc2725582..f41a4a3ca5 100644 --- a/app/controllers/admin/statuses_controller.rb +++ b/app/controllers/admin/statuses_controller.rb @@ -49,8 +49,13 @@ def new_or_edit end if @status.save - @status.send_to_twitter(current_user) if params[:status][:push_to_twitter] and @status.twitter_id.nil? or @status.twitter_id.empty? flash[:notice] = _("Status was successfully %s.", message) + if params[:status][:push_to_twitter] and @status.twitter_id.nil? or @status.twitter_id.empty? + unless @status.send_to_twitter(current_user) + flash[:error] = _("Oooops something wrong happened") + flash[:notice] = nil + end + end redirect_to :action => 'new' end return diff --git a/app/models/status.rb b/app/models/status.rb index 613f62158a..97974b48f1 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -64,16 +64,15 @@ def send_to_twitter(user) message = "#{message}#{short_permalink}" end - puts message - begin tweet = twitter.update(message) self.twitter_id = tweet.attrs[:id_str] self.save user.update_twitter_profile_image(tweet.attrs[:user][:profile_image_url]) + return true rescue - flash[:error] = "Oooops something wrong happened" + return false end end