[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Create record into Oracle DB

Alexey Nik

2/18/2008 7:09:00 PM

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
--
Posted via http://www.ruby-....

7 Answers

Jesse Hu

2/20/2008 3:36:00 AM

0

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

On Feb 19, 3:08 am, Alexey Nik <sc_...@tut.by> wrote:
> 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
> --
> Posted viahttp://www.ruby-....

Alexey Nik

2/20/2008 8:30:00 AM

0

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 ?
--
Posted via http://www.ruby-....

Jesse Hu

2/21/2008 2:26:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

2008/2/20, Alexey Nik <sc_out@tut.by>:
>
> 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 ?
> --
> Posted via http://www.ruby-....
>
>
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?

--
Cheers,
Jesse

Alexey Nik

2/21/2008 10:56:00 AM

0

Jesse Hu wrote:
> 2008/2/20, Alexey Nik <sc_out@tut.by>:
>> > -
>> 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-....
>>
>>
> 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
--
Posted via http://www.ruby-....

Jesse Hu

2/22/2008 1:44:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

2008/2/21, Alexey Nik <sc_out@tut.by>:
>
> Jesse Hu wrote:
> > 2008/2/20, Alexey Nik <sc_out@tut.by>:
> >> > -
> >> 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-....
> >>
> >>
> > 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
> --
> Posted via http://www.ruby-....
>
>
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.*

--
Cheers,
Jesse

Alexey Nik

2/22/2008 8:46:00 AM

0

Jesse Hu wrote:
> 2008/2/21, Alexey Nik <sc_out@tut.by>:
>> >> Posted via http://www.ruby-....
>> class CreateFolderTrees < ActiveRecord::Migration
>> Posted via http://www.ruby-....
>>
>>
> 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
}

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

Jesse Hu

2/22/2008 9:33:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

2008/2/22, Alexey Nik <sc_out@tut.by>:
>
> Jesse Hu wrote:
> > 2008/2/21, Alexey Nik <sc_out@tut.by>:
> >> >> Posted via http://www.ruby-....
> >> class CreateFolderTrees < ActiveRecord::Migration
> >> Posted via http://www.ruby-....
> >>
> >>
> > 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
> }
>
> --
> Posted via http://www.ruby-....
>
>
You can ask for help from the rails-talk mailing list [
rubyonrails-talk@googlegroups.com].

--
Cheers,
Jesse