Hi, I''m currently developing a web-application that is multilingual. I''m using ruby+gettext for the multilingual facility. Now I''d like to create a category view that acts_as_tree, but with multilingual :name- values. My ideal solution would be to not bind that category-model to the database, because the categories are just 50 or so, which won''t be updated dynamically. So I''d like to act that model as a tree, but fill in the data at class-instantiation time. like so: Class Category < ActiveRecord::Base acts_as_tree attr :name attr :parent_id attr :id def initialize fill_the_data end Can anybody help? Is this possible at all? My guess is "no", but I''ll wait for your replies, guys. Regards, wogri --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
njmacinnes-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-12 17:49 UTC
Re: acts_as_tree without database
But what would be wrong with binding it to the database? You could have the database populated in the migration, so that you don''t forget to do it or anything. If you really want to make sure your categories table is protected, you could override the class''s save method, destroy method, etc. -Nathan On Oct 12, 6:34 pm, wogri <wogri.wo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''m currently developing a web-application that is multilingual. I''m > using ruby+gettext for the multilingual facility. Now I''d like to > create a category view that acts_as_tree, but with multilingual :name- > values. > My ideal solution would be to not bind that category-model to the > database, because the categories are just 50 or so, which won''t be > updated dynamically. So I''d like to act that model as a tree, but fill > in the data at class-instantiation time. > > like so: > > Class Category < ActiveRecord::Base > > acts_as_tree > attr :name > attr :parent_id > attr :id > > def initialize > fill_the_data > end > > Can anybody help? Is this possible at all? My guess is "no", but I''ll > wait for your replies, guys. > > Regards, > wogri--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 12, 7:49 pm, njmacin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> But what would be wrong with binding it to the database? You could > have the database populated in the migration, so that you don''t forget > to do it or anything.There''s nothing wrong with binding it to the DB, but it doesn''t work with gettext, AFAIK. I want ONE central translation for my application with the po-files of gettext. wogri --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
njmacinnes-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-12 18:33 UTC
Re: acts_as_tree without database
Oh, I see. Sorry, didn''t read properly. I''ve asked a question just before you did about abstract_class. My question more or less asks if setting self.abstract_class to true does what you want it to do (although I''m doing it for a slightly different purpose). Nobody''s answered yet though. But have a look into that. Otherwise, you could overwrite all the database interaction methods for that class to prevent throwing exceptions, and have self.columns = []. On Oct 12, 6:57 pm, wogri <wogri.wo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 12, 7:49 pm, njmacin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > But what would be wrong with binding it to the database? You could > > have the database populated in the migration, so that you don''t forget > > to do it or anything. > > There''s nothing wrong with binding it to the DB, but it doesn''t work > with gettext, AFAIK. I want ONE central translation for my application > with the po-files of gettext. > > wogri--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 12, 8:33 pm, njmacin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Oh, I see. Sorry, didn''t read properly. I''ve asked a question just > before you did about abstract_class. My question more or less asks if > setting self.abstract_class to true does what you want it to do > (although I''m doing it for a slightly different purpose). Nobody''s > answered yet though.Thanks for your reply again; I''ve solved it in the mean time by saving the english data in the database, loading it, running the names through a "translation-hash", and re-sorting the translated names. Quite expensive, but I couldn''t think of any better in that short time; wogri --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---