我正在使用twitter gem与媒体发推文。该代码目前正在运行,但它没有显示推文表,允许用户在发送之前编辑推文的内容。我需要添加什么才能让用户编辑外发推文?
这是我的代码:
用户模型
def tweet_micard
micard_image = self.s3_images.last.image_url
uri = URI.parse(micard_image)
media = uri.open
media.instance_eval("def original_filename; '#{File.basename(uri.path)}'; end")
twitter_client.update_with_media("future tweet goes here", media)
end
def twitter_client
client = Twitter::REST::Client.new do |config|
config.consumer_key = "..."
config.consumer_secret = "..."
config.access_token = self.oauth_token
config.access_token_secret = self.oauth_secret
end
client
end
Twitter控制器
class TwitterController < ApplicationController
skip_authorization_check
def callback
current_user.update_attributes(oauth_token: env['omniauth.auth'][:credentials][:token], oauth_secret: env['omniauth.auth'][:credentials][:secret])
current_user.tweet_micard
redirect_to micard_path(current_user)
end
end