Skip to content

Commit

Permalink
Removes a debug, fixes a bug when a status fails to be created
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric de Villamil committed Aug 15, 2013
1 parent 13a2183 commit 2fdec2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/controllers/admin/statuses_controller.rb
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions app/models/status.rb
Expand Up @@ -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

Expand Down

0 comments on commit 2fdec2b

Please sign in to comment.