Oracle 10g Express - generate scaffold gives error


#1

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:ininitialize’
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:innew_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:innew’
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:insend’
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:inconnection=’
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:inconnection’
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:incount’
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:inpaginator_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:inlist’
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:inperform_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:inperform_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:inperform_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:insend’
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:inprocess’
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:inhandle_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:inservice’
e:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run' e:/ruby/lib/ruby/1.8/webrick/server.rb:155:instart_thread’
e:/ruby/lib/ruby/1.8/webrick/server.rb:144:in start' e:/ruby/lib/ruby/1.8/webrick/server.rb:144:instart_thread’
e:/ruby/lib/ruby/1.8/webrick/server.rb:94:in start' e:/ruby/lib/ruby/1.8/webrick/server.rb:89:ineach’
e:/ruby/lib/ruby/1.8/webrick/server.rb:89:in start' e:/ruby/lib/ruby/1.8/webrick/server.rb:79:instart’
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:indispatch’
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:inrequire’
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:inrequire__’
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:inrequire’
./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!


#2

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.


#3

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.


#4

Looks like you found a bug.


#5

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


#6

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