noosfero | Fixes relations namespaces in Orders and Suppliers plugin (!1110)
Gabriel Silva
gitlab at mg.gitlab.com
Wed Feb 22 21:42:33 BRT 2017
New comment for Merge Request !1110 on plugins/orders/models/orders_plugin/item.rb:
https://gitlab.com/noosfero/noosfero/merge_requests/1110#note_23993863
> has_one :to_product, through: :product
> has_many :sources_supplier_products, through: :product
> has_one :sources_supplier_product, through: :product
> - has_many :supplier_products, through: :product
> + has_many :supplier_products, through: :product, :class_name => "ProductsPlugin::Product"
I'm pretty sure that the `class_name` supports subclasses. There are several examples in Noosfero models, like the following snippet from [scrap.rb]:(https://gitlab.com/noosfero/noosfero/blob/master/app/models/scrap.rb#L13):
```ruby
class Scrap < ApplicationRecord
...
belongs_to :receiver, :class_name => 'Profile', :foreign_key => 'receiver_id'
belongs_to :sender, :class_name => 'Person', :foreign_key => 'sender_id'
...
end
```
In this case, the `receiver` can also be any kind of profile, and the class_name still works.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170223/d92202a9/attachment.html>
More information about the Noosfero-dev
mailing list