Create record into Oracle DB

Hello all, there is part of my code :
folder = Folder1.new()
folder.ID = @id
folder.CLIENT_NAME = @un
folder.TREE_NAME = @tn
folder.save()
when i test it on mySql all work right, but when i try it with Oracle i
got this error #NoMethodError (undefined method `ID=’ for
#FolderTree:0x4bae7cc).

I try again with other ruby method
Folder1.create(:ID => @id, :CLIENT_NAME => @un, :TREE_NAME => @tn)

and again got error : #NoMethodError (undefined method `CLIENT_NAME=’
for #FolderTree:0x4baf6a4)

Other actions (e.g. Folder1.find(:all,:conditions => “ID
=’”+Id.to_s+"’")) works good.

Smb know why Oracle return error #NoMethodError

why u use upper case name as the field name?
Please use lower case and try again:
folder = Folder.new()
folder.id= @id
folder.client_name = @un
folder.tree_name = @tn
folder.save()

Cheers,
Jesse

Jesse Hu wrote:

why u use upper case name as the field name?
Please use lower case and try again:
folder = Folder.new()
folder.id= @id
folder.client_name = @un
folder.tree_name = @tn
folder.save()

Cheers,
Jesse

I use upper case, because fields names in db have upper case
(
ID INTEGER,
CLIENT_NAME VARCHAR2(35 BYTE) NOT NULL,
TREE_NAME VARCHAR2(35 BYTE) NOT NULL,
)

I try lower case and got error : undefined method `id=’ for
#FolderTree:0x54060b0

Does anybody have solution of this problem ?

2008/2/20, Alexey N. [email protected]:

I try lower case and got error : undefined method `id=’ for
#FolderTree:0x54060b0

Does anybody have solution of this problem ?

Posted via http://www.ruby-forum.com/.

It has no relation to the character case of field names in db. You’d
better
use lower case string for the function name in Ruby.

How is your db migration file (001_create_fold_trees.rb
) for the FoldTree model like?

Jesse Hu wrote:

2008/2/20, Alexey N. [email protected]:

I try lower case and got error : undefined method `id=’ for
#FolderTree:0x54060b0

Does anybody have solution of this problem ?

Posted via http://www.ruby-forum.com/.

It has no relation to the character case of field names in db. You’d
better
use lower case string for the function name in Ruby.

How is your db migration file (001_create_fold_trees.rb
) for the FoldTree model like?

it’s conetns of 001_create_folder_trees.rb :
class CreateFolderTrees < ActiveRecord::Migration
def self.up
create_table :folder_trees do |t|
end
end

def self.down
drop_table :folder_trees
end
end

Jesse Hu wrote:

2008/2/21, Alexey N. [email protected]:

Posted via http://www.ruby-forum.com/.
class CreateFolderTrees < ActiveRecord::Migration
Posted via http://www.ruby-forum.com/.

That’s the problem. You need to define columns for the folder_trees
table
like this:

def self.up
create_table :folder_trees do |t|

  •    t.column :client_name, :string*
    
  •    t.column :tree_name, :string
    
    end
    end*
    **

Then run rake task “rake db:migrate” to create the table in db.

Table structure in DB already exist, like this:
{
CLIENT_NAME VARCHAR2(35 BYTE) NOT NULL,
TREE_NAME VARCHAR2(35 BYTE) NOT NULL
}

2008/2/22, Alexey N. [email protected]:

like this:

Table structure in DB already exist, like this:
{
CLIENT_NAME VARCHAR2(35 BYTE) NOT NULL,
TREE_NAME VARCHAR2(35 BYTE) NOT NULL
}


Posted via http://www.ruby-forum.com/.

You can ask for help from the rails-talk mailing list [
[email protected]].

2008/2/21, Alexey N. [email protected]:

Posted via http://www.ruby-forum.com/.
class CreateFolderTrees < ActiveRecord::Migration
Posted via http://www.ruby-forum.com/.

That’s the problem. You need to define columns for the folder_trees
table
like this:

def self.up
create_table :folder_trees do |t|

  •    t.column :client_name, :string*
    
  •    t.column :tree_name, :string
    
    end
    end*
    **

Then run rake task “rake db:migrate” to create the table in db.