Forum: Ruby on Rails Oracle 10g Express - generate scaffold gives error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Marius B. (Guest)
on 2006-01-10 23:19
Hello,
I have Oracle XE installed.
I have a table USERS.
When I try to generate a scaffold it gives me this error.
I tried also with Mysql and it worked.

E:\radrails\projects\MPS>ruby script\generate scaffold user
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/user
      exists  test/functional/
  dependency  model
      exists    app/models/
      exists    test/unit/
      exists    test/fixtures/
      create    app/models/user.rb
      create    test/unit/user_test.rb
      create    test/fixtures/user.yml
wrong argument type Fixnum (expected String)

and it generates only app/models/user.rb


I generated the model and the controller:
E:\radrails\projects\MPS>ruby script\generate model user
      create  app/models/
      create  test/unit/
      create  test/fixtures/
      create  app/models/user.rb
      create  test/unit/user_test.rb
      create  test/fixtures/user.yml

E:\radrails\projects\MPS>ruby script\generate controller users
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/user
      create  test/functional/
      create  app/controllers/user_controller.rb
      create  test/functional/user_controller_test.rb
      create  app/helpers/user_helper.rb

and I modified user_controller.rb like this:

class UserController < ApplicationController
	scaffold :user
end

I booted WebRick

E:\radrails\projects\MPS>ruby script/server
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2006-01-10 23:00:46] INFO  WEBrick 1.3.1
[2006-01-10 23:00:46] INFO  ruby 1.8.2 (2004-12-25) [i386-mswin32]
[2006-01-10 23:00:46] INFO  WEBrick::HTTPServer#start: pid=888 port=3000

and when loading http://127.0.0.1:3000/user/ I got

wrong argument type Fixnum (expected String)
RAILS_ROOT: ./script/../config/..

Application Trace | Framework Trace | Full Trace
e:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:155:in `attrSet'
e:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:155:in `initialize'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/oci_adapter.rb:515:in
`new'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/oci_adapter.rb:515:in
`new_connection'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/oci_adapter.rb:545:in
`initialize'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/oci_adapter.rb:35:in
`new'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/oci_adapter.rb:35:in
`oci_connection'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in
`send'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in
`connection_without_query_cache='
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/query_cache.rb:54:in
`connection='
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:106:in
`retrieve_connection'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:20:in
`connection'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:518:in
`count_by_sql'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:511:in
`count'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:167:in
`count_collection_for_pagination'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:188:in
`paginator_and_collection_for'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:124:in
`paginate'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/scaffolding.rb:101:in
`list'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in
`send'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in
`perform_action_without_filters'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in
`perform_action_without_benchmark'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
`measure'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in
`perform_action'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in
`send'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in
`process_without_session_management_support'
e:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in
`process'
e:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in
`dispatch'
e:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in
`handle_dispatch'
e:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in
`service'
e:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
e:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
e:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread'
e:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start'
e:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread'
e:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start'
e:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each'
e:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start'
e:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'
e:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'
e:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in
`dispatch'
e:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59
e:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require__'
e:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require'
e:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28
e:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require__'
e:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require'
./script/server:3
-e:3:in `load'
-e:3


In /config/database.yml I tried all the combinations above
development:
   adapter: oci
   database: xe
   host: xe
   username: mps
   password: 123

test:
  adapter: oci
  database: xe
  host: xe
  username: mps
  password: 123

production:
  adapter: oci
  database: xe
  host: //marius:1521/xe
  username: mps
  password: 123


I don't know where to look anymore.
Please help!
Leon L. (Guest)
on 2006-01-11 14:41
(Received via mailing list)
I am using Oracle XE also and I have a model User.

I remember getting a problem with the Oracle reserve word "password"....
posting the fields in the user table may be helpful also.

another observation.
your development database and test database is the same. this is not
recommended.
In oracle you can simply create another user "mpstest" the test user
will
own all his objects in this schema.


regards,
Leon.
Marius B. (Guest)
on 2006-01-11 22:16
I resolved it - It didn't worked because of the password "123".

development:
   adapter: oci
   database: xe
   host: xe
   username: mps
   password: 123

I think oci8.rb expects a character password not a numerical one.
I changed the password to "mps".

development:
   adapter: oci
   database: xe
   host: xe
   username: mps
   password: mps

And now it works very well.

Thanks.
Leon L. (Guest)
on 2006-01-13 23:33
(Received via mailing list)
Looks like you found a bug.
KUBO Takehiro (Guest)
on 2006-01-14 07:24
(Received via mailing list)
Leon L. <removed_email_address@domain.invalid> writes:

> Looks like you found a bug.

It will be a 'database.yml' parsing problem.

>
>     I think oci8.rb expects a character password not a numerical one.
>     I changed the password to "mps".

oci8.rb expects an instance of String class as a password.
OCI8.new('mps', '123', 'xe') works. But OCI8.new('mps', 123, 'xe')
doesn't work.

I looks like that when a parameter value looks like a numerical one,
an instance of Numeric class is retrieved.

It may be solved temporarily in oci8.rb by calling password.to_s when
the password is not an instance of String. But I guess if the password
is "5.000", a Float value 5.0 is passwd to oci8.rb and to_s returns
"5.0", which isn't recoverable.

It needs to fix 'database.yml' parsing code.

--
KUBO Takehiro
email: removed_email_address@domain.invalid
web:   http://www.jiubao.org
GnuPG fingerprint = 5F7B C8EF CA16 57D0 FDE1  9F47 C001 1F93 AC08 2262
KUBO Takehiro (Guest)
on 2006-03-05 09:16
(Received via mailing list)
KUBO Takehiro <removed_email_address@domain.invalid> writes:

>>
>>     I think oci8.rb expects a character password not a numerical one.
>>     I changed the password to "mps".

YAML parses 123 as a Fixnum value. Use "123" instead.

    development:
       adapter: oci
       database: xe
       host: xe
       username: mps
       password: "123"

oci8.rb expects a String not a Fixnum as a password.

--
KUBO Takehiro
email: removed_email_address@domain.invalid
web:   http://www.jiubao.org
GnuPG fingerprint = 5F7B C8EF CA16 57D0 FDE1  9F47 C001 1F93 AC08 2262
This topic is locked and can not be replied to.