9
我有一個從入門車型繼承了以下mongoid型號:頂級恆定
class Entry::Twitter < Entry
field :retweet_count, :type => Integer, :default => 0
field :retweeted, :type => Boolean, :default => false
field :favorited, :type => Boolean, :default => false
# in_reply_to_screen_name, in_reply_to_status_id_str, in_reply_to_user_id_str
field :reply, :type => Hash
field :from, :type => Hash # user: id_str, name, screen_name
field :time, :type => Time # created_at
field :data, :type => Hash # entities (hashtags and user_mentions)
field :assets, :type => Hash # urls from original entities
field :service, :type => String, :default => "twitter"
attr_accessible :assets
# validations
validates_presence_of :retweet_count, :from, :time, :data
# override set_service cause of https://github.com/sferik/twitter/issues/303
def set_service
self.service = "twitter"
end
end
當我嘗試引用它,我得到以下警告:
ruby-1.9.3-p125 :001 > Entry::Twitter
(irb):1: warning: toplevel constant Twitter referenced by Entry::Twitter
=> Twitter
不是引用我的模型,而是引用由寶石定義的頂級常量Twitter。
我能做些什麼來解決這個問題?我不想爲我的班級使用別的名字。
你的意思是哪個寶石是exaclty?這一個:https://github.com/sferik/twitter?我有一個類似的問題,並加載錯誤。 – Mattherick 2012-08-13 10:27:09
你的問題與Ruby如何處理範圍有關。這裏有一個很好的描述發生了什麼:http://stackoverflow.com/a/6282245/279024 – rubiii 2012-08-13 11:32:13
@rubiii我已經看到了這一點。但我不知道如何將這個應用到我的具體問題。 – Mindbreaker 2012-08-13 11:48:00