`type` attribute is of which model ?? I guess it is of property model and
`values` method wrote inside property model, right ?
ProductPropertyString, ProductPropertyBoolean, ProductPropertyInteger are
these models ??
if yes, why do you need association ?
"has_many: values,: class_name =>
''ProductProperty''"
On Tue, Apr 12, 2011 at 12:20 PM, Vasin Alexander
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:
> Sorry for my english if something goes wrong.
> I have a model of Property
>
> class Property <ActiveRecord:: Base
> has_many: values,: class_name => "ProductProperty"
> End
>
> And correspondingly ProductProperty model in which values are stored.
>
> class ProductProperty <ActiveRecord:: Base
> belongs_to: product
> belongs_to: property
> end
>
> Now the stored values are of type String. Do I have a need to store
> different types of Integer, Boolean and String. I came up just one idea
> how to implement it. Add to the model Property column type. And rewrite
> the method values:
>
> def values
> case self.type
> when ''ProductPropertyString''
> ProductPropertyString.where(:property_id => self.id)
> when ''ProductPropertyBoolean''
> ProductPropertyBoolean.where(:property_id => self.id)
> when ''ProductPropertyInteger''
> ProductPropertyInteger.where(:property_id => self.id)
> end
>
> Maybe somebody has already faced with this challenge and how to solve it
> correctly?
>
> --
> 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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
sαη∂ιρ Rαηѕιηg
---
www.funonrails.com
twitter, github @sandipransing
skype sandip.ransing
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.