Composite primary keys

19 views
Skip to first unread message

cschlaefcke

unread,
May 7, 2007, 7:45:36 AM5/7/07
to ActiveScaffold : Ruby on Rails plugin
Hi Folks,

I need to map a table with a composite primary key. I found this
plugin:

http://compositekeys.rubyforge.org

for adding composite pk support to ActiveRecord. It seems that AR
works fine with it but AS throws this:

ActionView::TemplateError (can't convert
CompositePrimaryKeys::CompositeKeys into String) on line #3 of vendor/
plugins/active_scaffold/frontends/default/views/_form.rhtml:

when scaffolding the model with the composite keys.

Are composite primary keys supported by AS? Anyone here with
experiences on that?

Thanks & Regards,

Christian

purplehaze

unread,
Jun 7, 2007, 8:47:40 AM6/7/07
to ActiveScaffold : Ruby on Rails plugin
Have the same error.
I have to work with old legacy Sybase DB (about 3000 tables and views)
Most of the table have 2-10 columns as primary key.
http://compositekeys.rubyforge.org plugin works.

but ActiveScaffold sucks with the same error. :(


Roman

Michael Latta

unread,
Jun 7, 2007, 12:46:03 PM6/7/07
to actives...@googlegroups.com
What I did was to create a facade class that does not inherit from
ActiveRecord then make the "id" show the primary key. In my case the
primary key was computed from other data and could change as a result
of an edit, so I had to override ActiveScaffold in a few places to
allow for the primary key changing after an update. But, all in all
it works and is fairly straightforward. Start with an empty class
and just resolve messages that are not understood. In your case you
could even just redirect all messages to a wrapped ActiveRecord while
replacing the id and id= methods, and filtering the [] and []= methods.

Michael

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "ActiveScaffold : Ruby on Rails plugin" group.
> To post to this group, send email to actives...@googlegroups.com
> To unsubscribe from this group, send email to activescaffold-
> unsub...@googlegroups.com
> For more options, visit this group at http://groups.google.com/
> group/activescaffold?hl=en
> -~----------~----~----~----~------~----~------~--~---
>

Reply all
Reply to author
Forward
0 new messages