On Martes, 22 de Septiembre de 2009 22:43:34 Chris Drappier escribió: > Hi All, > > I have a relationship utilizing the :primary_key option which AS does not > seem to respect. here's how it looks > > class Item < ActiveRecord::Base > has_many :source_links, :class_name => "Link", :foreign_key => > > :src_pduid, :primary_key => :pduid > > end > > class Link < ActiveRecord::Base > belongs_to :source_item, :class_name => "Item" , :foreign_key => > > :src_pduid, :primary_key => :pduid > > end >
I have tried setting the primary key in the model with set_primary_key, and I haven't need the primary_key option. class Item < ActiveRecord::Base set_primary_key 'pduid' end Really, I couldn't load items controller until I add set_primary_key If I haven't understood your problem post your tables > class ItemController < ApplicationController > active_scaffold do |config| > config.list.columns = [:item_type, :cradle_id, :name, :version, > > :name, :owner, :target_links, :source_links] > > config.columns[:target_links].association.reverse = :target_item > config.columns[:source_links].association.reverse = :source_item > end > end > > class LinksController < ApplicationController > active_scaffold do |config| > config.columns = [:source_item, :target_item] > config.columns[:source_item].association.reverse = :source_links > config.columns[:target_item].association.reverse = :source_links > end > end > > when i'm looking at localhost:3000/items, and i click on the link in > source_links or target_links for any given item, it returns an empty set. > I've verified that the given item should have links in both arrays, and > that i can call item.source_links from the console and get the proper > result. when i look at the sql output in the server log, it is doing this > select based on the item id, rather than the item pduid. I've been banging > my head against the wall for a couple of hours trying to figure this one > out, but I can't seem to find the solution. help would be much appreciated > > > tyvm > > -C > > -- Sergio Cambra .:: entreCables S.L. ::. Mariana Pineda 23, 50.018 Zaragoza T) 902 021 404 F) 976 52 98 07 E) [email protected] --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en -~----------~----~----~----~------~----~------~--~---
