I should have written that I'm still on 2.3.14.
Is there some new code for Polymorphic links in 3.2 that I might look at back
porting to 2.3 ?
/S
On Feb 22, 2012, at 3:16 AM, Sergio Cambra wrote:
> I have checked with latest active scaffold (3.2.0) and it works
>
> On Domingo, 12 de febrero de 2012 18:06:56 Soren escribió:
>> Hi
>>
>> I have a simple test that uses a Polymorphic relationship - see below
>> - and grossly simplified.
>>
>> Running this through the obvious AS controllers behaves as one would
>> expect. You can create orders from the various Customer controllers
>> and things are just fine.
>> However, I need to have a way to explore the data about the customer
>> from the orders controller.
>>
>> Crudely(very!!) this can be done by mimicking a show_action. So if one
>> places this in orders_helper.rb:
>> def order_customer_column(record)
>> "<a href='/customer1s/#{record.customer_id}?
>> _method=get&parent_controller=orders' class='show action order'
>> id='as_orders-customer1s-show-#{record.customer_id}-link'
>> position='after'>#{record.customer.name} </a>"
>> end
>> I get a show action - and I can turn it into an edit etc etc - Ugly!
>>
>> But there must be a better way to do this - and preferably one that
>> gives me access to the customers as a nested action - just like the
>> order_items in the code above.
>>
>> This ought to be obvious - but I have stared at it so long I can not
>> see it. Suggestions ?
>>
>> Code:
>> class Customer1 < ActiveRecord::Base
>> has_many :orders, :as => :customer
>> end
>>
>> class Customer2 < ActiveRecord::Base
>> has_many :orders, :as => :customer
>> end
>>
>> class Order < ActiveRecord::Base
>> belongs_to :customer, :polymorphic => true
>> has_many :order_items
>> end
>>
>> class OrderItem < ActiveRecord::Base
>> belongs_to :order
>> end
>> class Customer1sController < ApplicationController
>> active_scaffold :customer1s do |config|
>> end
>> end
>>
>> class Customer2sController < ApplicationController
>> active_scaffold :customer2s do |config|
>> end
>> end
>>
>> class OrderItemsController < ApplicationController
>> active_scaffold :order_items do |config|
>> end
>> end
>>
>> class OrdersController < ApplicationController
>> active_scaffold :orders do |config|
>> end
>> end
>>
>>
>> /S
>
> --
> 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.
>
--
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.