Error - Ruby OCI8 - Wrong number of arguments (2 for 0..1) - sql

When running this script:
require 'oci8'
conn = OCI8.new('username', 'password', 'tnsname')
cursor = conn.exec('SELECT 1+1 FROM dual')
while r = cursor.fetch()
puts r.join(',')
end
cursor.close
conn.logoff
The following error message occurs:
C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `initi
alize': wrong number of arguments (2 for 0..1) (ArgumentError)
from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:36:in `new'
from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:36:in `require'
from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:36:in `require'
from C:/tech/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5-x86-mingw3
2/lib/oci8.rb:81:in `<top (required)>'
from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:60:in `require'
from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:60:in `rescue in require'
from C:/tech/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:35:in `require'
from u:/Ruby/test_oci_connect.rb:1:in `<main>'
I can use those credentials in SQLPLUS and I have both the gems and devkit installed. Can anyone assist with this issue or provide some clarity regarding the answer below?

The issue is caused by a mismatch in the Oracle DLLs architecture and your Ruby installation, or your System not finding the right DLLs.
Download the Oracle Instant Client. Its important that its the same arch that your Ruby is in, as it contains the necessary DLLs.
Unzip it somewhere on your HDD, such as:
C:/OracleInstantClient Its also convenient to add both
/network/admin/sqlnet.ora
/network/admin/tnsnames.ora to that folder.
Add the Instant Client's location to your System PATH. You should now be able to connect without that error, provided you've added the correct connection information.

I was getting the same error message, using a gem dependent on ruby-oci8 (dm-oracle-adapter for datamapper).
Re-ran the install as per these instructions on a fresh environment :
Installing instant client for ruby-oci8
Double checked the path was set correctly and restarted my ruby console.
And everything worked perfectly.
On the machine it didn't work on (above incorrect arguments error), I have Oracle 64 bit dlls installed for some other services. My theory is that it was conflicting with these dlls (Ruby-oci8 needs 32bit DLLs), even though there was nothing pointing to these in the path.
Also, if you get the warning "ext/oci8 not found" when running 'gem install ruby-oci8', let me save you some time. In my case, this was a red herring and didn't affect the function of the gem at all.

That problem doesn't seem related to OCI8 at all.
You are misleading us a little here by not showing the whole code.
From your error stack trace, I can tell that you have a class that's trying to initialize but you have defined a parameter to that method and you didn't mention it when creating your object.
What this really means is that you mentioned 2 parameters where it was expecting either nothing or just one parameter.
if you create a test.rb fiel and paste the code you show us above all by itself, does it work?

Related

Michael Hartl Chapter 3.3.1 Rails Test error message

Ive followed the tutorial word by word, and I'm using the Cloud9 platform to follow along.
I'm supposed to run: $ rails test
I'm supposed to get: 2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
I'm not sure if i'm running the wrong command since i'm using Cloud9, but when I run the program the pages work, meaning I shouldn't be getting any errors at all. It's almost as if the test's never run at all. Any ideas?
enter code he(static-pages) $ rails test
Running via Spring preloader in process 5822
Run options: --seed 31158
Running:
...
Finished in 0.554944s, 5.4060 runs/s, 5.4060 assertions/s.
/usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/test_unit/minitest_plugin.rb:9:in aggregated_results': wrong number of arguments (given 1, expected 0) (ArgumentError)
from /usr/local/rvm/gems/ruby-2.3.0/gems/minitest-5.10.2/lib/minitest.rb:597:inreport'
from /usr/local/rvm/gems/ruby-2.3.0/gems/minitest-reporters-1.1.9/lib/minitest/minitest_reporter_plugin.rb:26:in each'
from /usr/local/rvm/gems/ruby-2.3.0/gems/minitest-reporters-1.1.9/lib/minitest/minitest_reporter_plugin.rb:26:inreport'
from /usr/local/rvm/gems/ruby-2.3.0/gems/minitest-5.10.2/lib/minitest.rb:687:in each'
from /usr/local/rvm/gems/ruby-2.3.0/gems/minitest-5.10.2/lib/minitest.rb:687:inreport'
from /usr/local/rvm/gems/ruby-2.3.0/gems/minitest-5.10.2/lib/minitest.rb:141:in run'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/test_unit/minitest_plugin.rb:73:inrun'
from /usr/local/rvm/gems/ruby-2.3.0/gems/minitest-5.10.2/lib/minitest.rb:63:in block in autorun'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:161:infork'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:161:in serve'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:131:inblock in run'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in loop'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:inrun'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in <top (required)>'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require'
from -e:1:in're
Ugg just found out this question was already answered elsewhere.
Apparently there is a bug in the Minitest Gem file.
I added the code below to the test/test_helper.rb file to resolve it. However, i'm pretty sure there are other ways to resolve it as well.
Minitest::Reporters.use!

Failed to use mongrel on Windows server with Rails 3 and Ruby 2.1

I'm trying to install redmine on a windows 2008 server.
It works with webrick.
Now I'm trying to put it in production with mongrel.
But when I start mongrel I have the following error:
E:/Ruby/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- 2.1/http11 (LoadError)
from E:/Ruby/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from E:/Ruby/Ruby21/lib/ruby/gems/2.1.0/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:17:in rescue in \<top (required)>'
from E:/Ruby/Ruby21/lib/ruby/gems/2.1.0/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:13:in\'
from E:/Ruby/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in require'
from E:/Ruby/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from E:/Ruby/Ruby21/lib/ruby/gems/2.1.0/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:13:in \<top (required)>'
from E:/Ruby/Ruby21/bin/mongrel_rails:23:inload'
from E:/Ruby/Ruby21/bin/mongrel_rails:23:in `'
I don't really know Ruby and can't figure out what the error means.
Thanks for your help
I'm not familiar with redmine, but I think problem is that you want to run Mongrel server, which is very old, and maybe not compatible with ruby2 (which you use). You can try add to Gemfile.local gem 'thin', for example, and make bundle install. I hope this manual will help you.

as_paperclip_bridge initialization error in rails3

I'm trying to use both of PaperClip and ActiveScaffold with help of as_paperclip_bridge in a rails3.0.5 project.
However, following initialization error is occurred when I launch the project.
=> Booting WEBrick
=> Rails 3.0.5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
C:/Users/ken/Documents/NetBeansProjects/fcheck/vendor/plugins/as_paperclip_bridge/init.rb:10: undefined method bridge' for ActiveScaffold:Module (NoMethodError)
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/plugin.rb:81
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:25:ininstance_exec'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:25:in run'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:50:inrun_initializers'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:49:in each'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:49:inrun_initializers'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:134:in initialize!'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:77:insend'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:77:in method_missing'
from C:/Users/ken/Documents/NetBeansProjects/fcheck/config/environment.rb:7
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:inrequire'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:inload_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:596:in new_constants_in'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:inload_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in require'
from C:/Users/ken/Documents/NetBeansProjects/fcheck/config.ru:3
from C:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:ininstance_eval'
from C:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in initialize'
from C:/Users/ken/Documents/NetBeansProjects/fcheck/config.ru:1:innew'
from C:/Users/ken/Documents/NetBeansProjects/fcheck/config.ru:1
The code in as_paperclip_bridge\init.rb is attempting to call a module method 'ActiveScaffold.bridge' but it coun't be found.
Even though, same code is working without error in rails2.3.8 project.
We can see a big difference of rails initialization code between version 2 and 3.
On rails 2.3.8, plugins are loaded in 'load_plugins' method which is called after 'load_gems' method in initializer.rb. However, rails3 doesn't have initializer.rb and the loading process seems to be totally different.
I also have tried to remove AS gem and install both of AS plugin with as_paperclip_bridge plugin. But, the error haven't disappeared.
Could someone explain why the error is occurring?!
Anyway, I really hope to get any solution or workaround.
Thanks,
Kenichi
Self reply.
I had realized that as_paperclip_bridge was not required for latest ActiveScaffold implementation. (It's including the bridge)
Please make sure to install ImageMagick and RMagick gem to use PaperClip for image files. Or, you may also think 'as_paperclip_bridge should be there'
Thank you,
Kenichi

Bundle install Jquery-rails taking too long to respond from gemcutter

Hi guys the gem jquery-rails(0.2.7) cant seem to be installed on my machine saying there are too many connections and it times out, I know this is not actualy programming but it is a fundamental for any ROR programmer esp in rails 3, so i'm actually looking for any1 who might have came across this error and resolved it. The error is as follows.
/usr/local/lib/site_ruby/1.8/rubygems/remote_fetcher.rb:365:in request': too many connection resets (http://production.cf.rubygems.org/gems/libxml-ruby-1.1.4.gem) (Gem::RemoteFetcher::FetchError)
from /usr/local/lib/site_ruby/1.8/rubygems/remote_fetcher.rb:289:inopen_uri_or_path'
from /usr/local/lib/site_ruby/1.8/rubygems/remote_fetcher.rb:298:in open_uri_or_path'
from /usr/local/lib/site_ruby/1.8/rubygems/remote_fetcher.rb:172:infetch_path'
from /usr/local/lib/site_ruby/1.8/rubygems/remote_fetcher.rb:110:in download'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/source.rb:253:indownload_gem_from_uri'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/source.rb:76:in fetch'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/installer.rb:45:inrun'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:ineach'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/installer.rb:44:in run'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/installer.rb:8:ininstall'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/cli.rb:217:in install'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor/task.rb:22:insend'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor/task.rb:22:in run'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor/invocation.rb:118:ininvoke_task'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor.rb:246:in dispatch'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor/base.rb:389:instart'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/bin/bundle:13
from /usr/bin/bundle:19:in `load'
from /usr/bin/bundle:19
Thanks in advance
~D
This is a connection issue. Try running the command again will install the gem.

undefined method `cache_sweeper' for ActionController::Base:Class - warbler

I am deploying my Jruby Rails application on glassfish with acts_as_audited as a gem/plugin installed.
Whenever I try to Audit my model, I am going to get the following error.
My Environment is: Jruby 1.6.0.RC2, Rails 3.0.3
You can refer here if you guys want to look more on the error http://www.ruby-forum.com/topic/1053934
Please help me out, I stuck up here
Application Error
org.jruby.rack.RackInitializationException: undefined method `cache_sweeper' for ActionController::Base:Class
from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/acts_as_audited-2.0.0.rc6/lib/acts_as_audited.rb:44:in `class_eval'
from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/acts_as_audited-2.0.0.rc6/lib/acts_as_audited.rb:44
from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/acts_as_audited-2.0.0.rc6/lib/acts_as_audited.rb:68:in `require'
from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
... 20 levels...
I reported this problema as a bug in jruby-rack.
A workaround is to add require 'active_record' if defined? $servlet_context after require 'rubygems' in config/boot.rb or manually including sweeping somwhere in application.rb ActionController::Base.send(:include, ActionController::Caching::Sweeping) if defined? $servlet_context.
I think I recognise this problem. It looks like acts_as_audited uses cache sweepers. I've had this problem with cache sweepers.
You need to explicitly include the caching module in your ApplicationController:
class ApplicationController < ActionController::Base
# JRuby not finding cache sweeper at runtime in production
include ActionController::Caching::Sweeping if defined?(JRUBY_VERSION)
# Rest of your class here...
end
I'm not sure why this happens, but it's probably a loading/resolution issue related to running in threadsafe mode for production.