There's this snazzy captcha that asks questions rather than displaying pictures. You can read about it at textcaptcha.com. Anyway. I want to use that with Ruby on Rails. A developer by the name of Matt Hutchinson wrote a Gem for easily connecting to the API. He has a set of instructions next to his source files on github. Anyway, It looks pretty simple but in trying to implement it I get this error every time:
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'
The root of my question has a bit less to do with this specific gem, and a little more with how gems work. I've installed the gem, and then bundled it inside of my rails app, it should be accessible (as I understand it). I see references to the gem in the gemfile.rb and the gemfile.lock, but again and again it tells me I'm using and undefined method.
The gem should be defining the method for me, should it not? Or is there something that I manually have to do?
Just let me know if there is any other info that would be helpful, thanks!
Well, jeez. It's working now. It could be that I restarted the server, but I'm not positive. What I did was installed RubyMine to see if I could use it's debugger, in doing so it required that I run the bundle install (it chose some different versions of some dependancies) through there, and also stop my other webrick server, to run the one through the RubyMine console. I did so, it gave me errors, when when I went back to my other installer it worked!?
Anyway, I've got my question resolved, but in the event that anyone looks this up, these are my current gems:
$ 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.
Thanks all!
But if you are trying this, do try restarting the server first as suggested, I wish I knew if that would have worked :D
Related
I'm getting an error trying to set up a Ruby on Rails site. I've never used Ruby before, so everything is clean out of the installer.
I've installed Ruby 1.9.3 and RubyGems 2.0.3. I then installed rails using gem and created a blank site with rails new. At some point I also installed the DevKit as instructed here - I can't remember when exactly, but I was explicitly asked to at some point. I then tried to start it using rails server, but it's asking me to use bundle install to install some missing gems. Easy enough, but when I try that I get the following output:
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.0.4)
Using i18n (0.6.1)
Using multi_json (1.7.3)
Using activesupport (3.2.13)
Using builder (3.0.4)
Using activemodel (3.2.13)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.2)
Using tilt (1.4.1)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Using mime-types (1.23)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.5.3)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.37)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
Using bundler (1.3.5)
Using coffee-script-source (1.6.2)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.3)
Installing json (1.7.7)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
"C:/Ruby/Ruby 1.9.3/bin/ruby.exe" extconf.rb
C:/Ruby/Ruby 1.9.3/bin/ruby.exe: invalid option -1 (-h will show valid options) (RuntimeError)
Gem files will remain installed in C:/Ruby/Ruby 1.9.3/lib/ruby/gems/1.9.1/gems/json-1.7.7 for inspection.
Results logged to C:/Ruby/Ruby 1.9.3/lib/ruby/gems/1.9.1/gems/json-1.7.7/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.7.7), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.7'` succeeds before bundling.
I get the same error when running either gem install json -v '1.7.7' or just gem install json. This particular error has proved itself resistant to Googling, so I thought I'd try asking here. Any help would be appreciated!
Well, it turns out the problem was that the path to my Ruby install has spaces in it. This is apparently strongly disrecommended in a number of places, but the error message was unrelated enough that it took me a while to put two and two together.
Started learning ruby on rails today, after spending the half day fixing the other errors, I am stuck at the following: When I enter the following command in the terminal: " bundle exec rake db:migrate" or "rails server" it gives me the following error:
Could not find rake-0.9.2 in any of the sources
Run bundle install to install missing gems.
I ran bundle install rake (Both with version number and without) and it says it has been installed to ./rake. When I run the command it gives me the same error again. No Idea how to fix this, so any help is wholeheartedly appreciated. I am using ruby 1.9.2 and rails 3.0.9 in the directory the App is located in with RVM. Thanks in advance for any help.
EDIT:
* LOCAL GEMS *
Using rake (0.9.2)
Using abstract (1.0.0)
Using activesupport (3.0.9)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.9)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.9)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.19)
Using actionmailer (3.0.9)
Using arel (2.0.10)
Using activerecord (3.0.9)
Using activeresource (3.0.9)
Using bundler (1.0.15)
Using rdoc (3.8)
Using thor (0.14.6)
Using railties (3.0.9)
Using rails (3.0.9)
Using sqlite3-ruby (1.2.5)
EDIT2: This has been fixed: Try using rvm and go back to ruby 1.8.7 instead of 1.9.2. This fixed it for me. Don't forget to install rails again (sudo gem install rails while already on 1.8.7) if you have only installed rails for 1.9.2.]
First, you should unlock the Gemfile
[root#localhost ~]#cd yourapplication [root#localhost
yourapplication]#bundle unlock
Then, edit your Gemfile, add gem rake
[root#localhost yourapplication]#vi Gemfile
+ gem 'rake', '0.9.2'
Then, update bundle
[root#localhost yourapplication]#bundle update
I guess you tried already gem install rake but it should come with rails anyway.
Well, what fl00r said in comments above, or show us the output of gem list --local
I'm trying to get set up to make front-end changes to a Rails 2.3.3 app, and I cannot get the environment set up in a way the application will start up (with script/server). I'm using RVM to run Ruby 1.8.7 with Rails 2.3.3, but when I try to start the server I get the following error:
/Users/myusername/.rvm/gems/ruby-1.8.7-p334#rails233/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:55:uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)
followed by the trail of filed to get there. Googling led me to add require 'thread' to boot.rb so my error changes to
/Users/myusername/.rvm/gems/ruby-1.8.7-p334#rails233/gems/postgres-pr-0.6.3/lib/postgres-pr/connection.rb:165:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
followed by the long trail of files it went through to get there. After Googling the error for a while, I think it has something to do with either my database.yml or some problem with actionmailer but I'm pretty much at a loss. I don't know if this is nearly enough information for anyone to help me but if you have any ideas just let me know. Also my list of gems is:
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.8, 2.3.3)
actionpack (3.0.8, 2.3.3)
activemodel (3.0.8)
activerecord (2.3.3)
activeresource (2.3.3)
activesupport (3.0.8, 2.3.3)
arel (2.0.10)
builder (3.0.0, 2.1.2)
erubis (2.6.6)
faker (0.3.1)
i18n (0.6.0, 0.5.0)
mail (2.2.19)
mime-types (1.16)
polyglot (0.3.1)
postgres-pr (0.6.3)
rack (1.2.3, 1.0.1)
rack-mount (0.6.14)
rack-test (0.5.7)
rails (2.3.3)
rake (0.8.7)
sqlite3 (1.3.3)
treetop (1.4.9)
tzinfo (0.3.27)
thanks for anything you can suggest!
That error has come up a couple times on me and as far as I know there isn't really a good solution. It comes from an incompatibility between rails 2.3.8 & lower and recent versions of ruby gems.
I suggest trying to use rails 2.3.11 or higher instead.
Refer to a previous question regarding this error:
Uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)
I'm really having a hard time solving this since I don't see any possible solutions that is already written on the net, So I decided to ask a question here at StackOverflow.
Firstly, I have created a new Rails app called "MicroTwitter":
rails new MicroTwitter -T
Here the -T option to the rails command tells Rails not to generate a test directory
associated with the default Test::Unit framework.
After that, I added a few lines on the Gemfile:
group :development do
gem 'rspec-rails'
end
group :test do
gem 'rspec'
gem 'webrat'
end
And so I did a bundle install
But after minutes of waiting, It was stuck up.
C:\Users\MDF\Desktop\apps\rails apps\MicroTwitter>bundle install
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.5)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.5)
Using erubis (2.6.6)
Using rack (1.2.2)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.26)
Using actionpack (3.0.5)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.15)
Using actionmailer (3.0.5)
Using arel (2.0.9)
Using activerecord (3.0.5)
Using activeresource (3.0.5)
Using bundler (1.0.11)
Using diff-lcs (1.1.2)
Using nokogiri (1.4.4.1)
Using thor (0.14.6)
Using railties (3.0.5)
Using rails (3.0.5)
Using rspec-core (2.5.1)
Using rspec-expectations (2.5.0)
Using rspec-mocks (2.5.0)
Using rspec (2.5.0)
Using rspec-rails (2.5.0)
Using sqlite3 (1.3.3)
It stuck up just to sqlite3. To those who knew how to solve this problem, Your help is highly appreciated. Thanks!
Ok, I found out the problem.
I for got to install the "webrat" gem.
After I installed webrat:
gem install webrat
and did a bundle install again, It works like magic!
I guess I have to be more careful next time. Thank you for all the answers and comments! :)
I have very simple (in fact empty ) project which i have created by rails new MyProject command from command-line. So, i want to import it to NetBeans IDE. I click "new project" -> "RoR" -> "from existing source", select Ruby 1.9.2 (instead of embedded JRuby) in the wizard form. After that i have got errors [see the picture below]:
So.. i click OK. And then try to run the RoR application from NetBeans clicking on the run-button and i got the following error in the log-panel:
/home/ses/.rvm/rubies/ruby-1.9.2-p136/bin/ruby: No such file or directory -- script/server (LoadError)
So how to handle these two problems?
p.s. my application is working when i launch it from the console.
i use ruby-1.9.2 and RoR 3.0 and Netbeans 6.9.1 and Ubuntu 10.10
and, replying the comment to my question. yes, i performed following commands:
bundle install
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
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.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.15)
Using actionmailer (3.0.3)
Using arel (2.0.7)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.10)
Using mysql2 (0.2.6)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
bundle pack
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
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.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.15)
Using actionmailer (3.0.3)
Using arel (2.0.7)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.10)
Using mysql2 (0.2.6)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
Updating .gem files in vendor/cache
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Updating .gem files in vendor/cache
and following this page http://wiki.netbeans.org/FaqRubyRakeFetchingFailed
i did rake -D
this is what I did to get it working (had same problem):
New project > with existing sources
Tools > Ruby Platforms > select Ruby 1.9.2-p136 > Gem Manager > New Gems > rails > install
restart netbeans
open project (if it's not already opened) and right click > bundler > install
run
first of all, what you should't do is expect the debugger to work. because it's not going to work on netbeans, not on rails 3 (there are some hacks but they have problems).
secondly, Ruby on Rails Support Discontinued in NetBeans IDE. I loved the way Netbeans worked with rails 2.x, but I migrated to RubyMine because of it's support for Rails 3
hope this helps