Ruby on Rails
Saturday, September 27, 2014
Hi to all.
I am working for a translation agency and I have the task to create an auto-estimate system and ordering/invoicing administration system. I am stuck on how to manage the language pairs.
I created a Language model with the language name and a LanguagePair with a source language, a target language and a rate per words attributes. I tried with:
LanguagePair
belongs_to :source, :class_name => "Language", :foreign_key => "source_id"
belongs_to :target, :class_name => "Language", :foreign_key => "target_id"
and also by replacing the source and target in the LanguagePair with a string type and loading it with a Language.all.permutation(2).to_a and eliminate the need for nesting.
In the end I will create a sort of cart and lineitem model and add the LanguagePair to the cart as a LineItem.
Is there a "best" way to do this maybe with a Language self-referential model?
thanks in advance
-- I am working for a translation agency and I have the task to create an auto-estimate system and ordering/invoicing administration system. I am stuck on how to manage the language pairs.
I created a Language model with the language name and a LanguagePair with a source language, a target language and a rate per words attributes. I tried with:
LanguagePair
belongs_to :source, :class_name => "Language", :foreign_key => "source_id"
belongs_to :target, :class_name => "Language", :foreign_key => "target_id"
and also by replacing the source and target in the LanguagePair with a string type and loading it with a Language.all.permutation(2).to_a and eliminate the need for nesting.
In the end I will create a sort of cart and lineitem model and add the LanguagePair to the cart as a LineItem.
Is there a "best" way to do this maybe with a Language self-referential model?
thanks in advance
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c214ccfe-bc9a-4e5a-85fe-003a325fa2f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment