无法使用制作gem
从twitter gem制作Twitter :: Tweet我试图从Twitter gem制作Twitter :: Tweet类。我得到这个错误无法使用制作gem
undefined method `id' for #<Fabrication::Schematic::Runner:0x00000102da7c28>
这是我的加工商。
Fabricator(:twitter_tweet, from: 'Twitter::Tweet', class_name: 'Twitter::Tweet') do id "1"
text "tweet"
created_at Time.now
user {
id "created_by_social_id"
name "name"
location "location"
}
entites {
user_mentions nil
}
end
但我可以像这样手动创建它。
tweet = Twitter::Tweet.new(:id => "1", :created_at => Time.now.to_s,
:text => "text",
:user => {
:id => "created_by_social_id",
:name => "name",
:location => "location"
},
:entities => {:user_mentions => user_mentions})
我是否错过任何明显的东西?
回答:
Twitter的
我想你感到困惑如何use the Twitter
gem to create Tweets的:
client.update("I'm tweeting with @gem!")
这是如何创建一个新的鸣叫。这是基于这样的想法,你已经initialized an object &与变量client
相关:
#config/initializers/twitter.rb client = Twitter::REST::Client.new do |config|
config.consumer_key = "YOUR_CONSUMER_KEY"
config.consumer_secret = "YOUR_CONSUMER_SECRET"
end
代码
虽然没有直接回答使用fabrication
,我建议你要调整您的语法以适应加载此gem(连接到Twitter API),然后使用fabrication
对其进行排序
以上是 无法使用制作gem 的全部内容, 来源链接: utcz.com/qa/259103.html