I think convert from string is not a good solution, because we will
not be able to use WHERE and ORDER BY queries over attributes (e.g.
ORDER BY string and number is strongly different).
Also I think we need some kind of Query Builder e.g. :orderby => "#
{attriDef.field}" or :condition=> "#{attriDef.field} = ?".
"attriDef.field" should return a field name dependent on attribute
type.

On 12 авг, 00:43, jhaagmans <[email protected]> wrote:
> On 11 aug, 22:57, insect <[email protected]> wrote:
>
> > Thank you Jaap!
>
> > I thought about it previousely, but one problem exists with with
> > validation and strong types of attributes. As i understand
> > ProductAttribute should have several number of fields for different
> > types of values e.g. string, decimal, integer, boolean and etc. And
> > there should be an accessor wich will give us value from field
> > dependent on type wich was defined in ProductDefinition. Am I right?
>
> I have had a very long day and I now see that I may have
> misunderstood: you might not even need a many-to-many relation, am I
> right? There's always the possibility of just using has_many and
> belongs_to between the product and attribute table. Especially if you
> want to be able to, for example, destroy a product and its attributes,
> you don't want to care too much about double entries.
>
> As for the string, integer, boolean etc.: that's true. There are a few
> methods that come to mind and the first one is indeed creating fields
> for all these possibilities and just looking which field contains a
> value. You can evaluate whether it's a string, a boolean or an integer
> using the field it's in. However, I'm unsure whether that's the most
> robust solution. You could also store every value as a string and
> convert it back in your model.
>
>
>
> > May be we can collaborate over this problem?
>
> Sure, you can always contact me directly, but I'm no expert yet, I'm
> probably as much in the learning process as you are and the Rails
> community you've found here is full of true experts. Let's have my
> responses be evaluated by the community instead of taking them for
> truth. That way we can both learn.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to