Forum: Ruby on Rails [ActiveRecord] new connector implementation gives 'unknown attribute error'

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Gabriele Modena (Guest)
on 2009-05-18 00:47
(Received via mailing list)
Hi all,
I'm implementing an activerecord connector on top of a database driver
I wrote (in pure ruby).

The platform of reference is a Mac OSX 10.5 box with the shipped ruby
interpreter version 1.8.6 and activerecord 2.3.2.

Table creation and select queries work; I though have some problems
when I try to perform insertion.

As an example I created a table called 'albums':

ActiveRecord::Schema.define do
    create_table :albums do |table|
        table.column :title, :string
        table.column :performer, :string

class Album < ActiveRecord::Base

Manual insertion works:
sql>insert into albums (title, performer) values ('a', 'b');

| id  | title   | performer |
|  1 | a       | b             |

Selection seems to be working:

puts Album.find(:first)['title']



When I try to call the create method though I get an AttributeError:

album = Album.create(:title => 'Black and Blue', :performer => 'The
Rolling Stones')

base.rb:2745:in `attributes=': unknown attribute: title

When enabling Logger I get the following:

Exception occurred during reader method compilation.
Maybe "performer" is not a valid Ruby identifier?
compile error
attribute_methods.rb:211: syntax error, unexpected tSTRING_BEG
def "performer"; missing_attribute('"performer"', caller) unless
@attributes.has_key?('"performer"'); @attributes['"performer"']; end
attribute_methods.rb:211: syntax error, unexpected kEND, expecting
def "performer"; missing_attribute('"performer"', caller) unless
@attributes.has_key?('"performer"'); @attributes['"performer"']; end


May there be any problem with the implementation of my database
driver? Maybe type conversion?
I googled but I was not able to find any hint to solve this or at
least things I should check.

Kind regards.
This topic is locked and can not be replied to.