Howard Yeh wrote:
> Hi All,
> 
> When saving a record to a table that doesn't use primary key, the
> adapater raises
> 
> ActiveRecord::StatementInvalid: PGError: ERROR:  column "id" does not
> exist
> 
[....]
> 
> The problem is that ActiveRecord::Base.create
> would pass in the primary_key "id" for the
> parameter pk even though the ActiveRecord class
> doesn't have a primary key.

When would you ever want to use an AR model without a primary key?  The 
only case I can think of where Rails doesn't want a primary key is on 
habtm join tables, which don't have an associated model class.

[...]
>
> 
> Or is there a way to set the primary key to nil?
> 
> class Foo < ActiveRecord::Base
>  set_primary_key nil
>  primary_key # => ""
> end

Seems like a really bad idea.  Without a primary key, there is no way to 
uniquely identify a record.  Why do you want to do this?

> 
> Howard

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to