簡體   English   中英

在Ruby On Rails中使用Gems:未定義的方法?

[英]Using Gems with Ruby On Rails: Undefined method?

有一個時髦的驗證碼會問問題而不是顯示圖片。 您可以在textcaptcha.com上閱讀有關它的信息 無論如何。 我想在Ruby on Rails中使用它。 一位名叫Matt Hutchinson的開發人員編寫了Gem,可以輕松連接到API。 在github上的源文件旁邊有一組說明 無論如何,它看起來非常簡單,但是在嘗試實現它時,每次都會出現此錯誤:

undefined method `acts_as_textcaptcha' for #<Class:0x104098508>
Rails.root: /Users/cory/Documents/Learning/RoR/dpt

Application Trace | Framework Trace | Full Trace
app/models/citation.rb:20
app/controllers/citations_controller.rb:29:in `new'

我的問題的根源與該特定寶石無關,而與寶石的工作原理有關。 我已經安裝了gem,然后將其捆綁在我的rails應用程序中,應該可以訪問(據我了解)。 我在gemfile.rbgemfile.lock看到了對gem的引用,但是一次又一次地告訴我我正在使用undefined方法。

寶石應該為我定義方法,不是嗎? 還是我需要手動執行某些操作?

請讓我知道是否還有其他有用的信息,謝謝!

好吧,老兄 現在正在工作。 可能是我重新啟動了服務器,但我並不滿意。 我所做的是安裝RubyMine來查看是否可以使用它的調試器,這樣做需要在那兒運行bundle install(它選擇了一些依賴關系的不同版本),並停止其他webrick服務器來運行一個通過RubyMine控制台。 我這樣做了,當我回到其他安裝程序時,它給我帶來了錯誤! 無論如何,我的問題已經解決,但是如果有人找了,這是我目前的瑰寶:

$ bundle install
Using rake (0.8.7) 
Using abstract (1.0.0) 
Using activesupport (3.0.0) 
Using builder (2.1.2) 
Using i18n (0.4.2) 
Using activemodel (3.0.0) 
Using erubis (2.6.6) 
Using rack (1.2.1) 
Using rack-mount (0.6.13) 
Using rack-test (0.5.7) 
Using tzinfo (0.3.24) 
Using actionpack (3.0.0) 
Using mime-types (1.16) 
Using polyglot (0.3.1) 
Using treetop (1.4.9) 
Using mail (2.2.15) 
Using actionmailer (3.0.0) 
Using arel (1.0.1) 
Using activerecord (3.0.0) 
Using activeresource (3.0.0) 
Using bcrypt-ruby (2.1.4) 
Using acts_as_textcaptcha (2.2.0) 
Using bundler (1.0.10) 
Using thor (0.14.6) 
Using railties (3.0.0) 
Using rails (3.0.0) 
Using sqlite3-ruby (1.2.5) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

謝謝大家! 但是,如果您要嘗試此操作,請按照建議先嘗試重新啟動服務器,但願我知道那是否可行:D

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM