Hi all, I wrote a module which contains some methods for doing math functions. I want the module to be included in one of my rails models. Where is the best place to put it? Should I make it into a gem and do a gem install - or can I just put it somewhere in the rails directory? Thanks, Chris -- 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-/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 -~----------~----~----~----~------~----~------~--~---
hi,> I wrote a module which contains some methods for doing math functions. > I want the module to be included in one of my rails models. > > Where is the best place to put it? >if you put it under RAILS_ROOT/lib directory and assuming the name of the file and the name of the module match, then it will be automatically added by rails to the load_path and you can use it directly throughout your rails application. in recent versions of rails you can also add directories to the load_path directly by tweaking environment.rb (look at the code, there is a commented out example in there). But if we want convention over configuration i''d recommend lib. about making it a gem/plugin, I''d only do it if it''s going to be something really generic that you are going to be reusing in several projects. If not, it''s not worth the overwork. Regards, javier ramirez -- -------- Estamos de estreno... si necesitas llevar el control de tus gastos visita http://www.gastosgem.com !!Es gratis!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thanks Javier, that''s just the ticket. I have another question: Before I converted it into a rails app, my app used a yaml file and a csv file to lookup numbers for the math functions. How do these files translate into a rails app? - should I keep them as yaml and csv or can I change them into some sort of Active Record models? thanks, Chris javier ramirez wrote:> hi, >> I wrote a module which contains some methods for doing math functions. >> I want the module to be included in one of my rails models. >> >> Where is the best place to put it? >> > if you put it under RAILS_ROOT/lib directory and assuming the name of > the file and the name of the module match, then it will be automatically > added by rails to the load_path and you can use it directly throughout > your rails application. > > in recent versions of rails you can also add directories to the > load_path directly by tweaking environment.rb (look at the code, there > is a commented out example in there). But if we want convention over > configuration i''d recommend lib. > > about making it a gem/plugin, I''d only do it if it''s going to be > something really generic that you are going to be reusing in several > projects. If not, it''s not worth the overwork. > > Regards, > > javier ramirez > > -- > -------- > Estamos de estreno... si necesitas llevar el control de tus gastos > visita http://www.gastosgem.com !!Es gratis!!-- 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-/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 -~----------~----~----~----~------~----~------~--~---
Really up to you. Probably the only reason to put them into ActiveRecord is if you want to persist them to ActiveRecord store and have them updateable at some time in the future. On Apr 27, 9:12 pm, chris finch <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> thanks Javier, that''s just the ticket. > > I have another question: > Before I converted it into a rails app, my app used a yaml file and a > csv file to lookup numbers for the math functions. > How do these files translate into a rails app? - should I keep them as > yaml and csv or can I change them into some sort of Active Record > models? > > thanks, > Chris > > > > javier ramirez wrote: > > hi, > >> I wrote a module which contains some methods for doing math functions. > >> I want the module to be included in one of my rails models. > > >> Where is the best place to put it? > > > if you put it under RAILS_ROOT/lib directory and assuming the name of > > the file and the name of the module match, then it will be automatically > > added by rails to the load_path and you can use it directly throughout > > your rails application. > > > in recent versions of rails you can also add directories to the > > load_path directly by tweaking environment.rb (look at the code, there > > is a commented out example in there). But if we want convention over > > configuration i''d recommend lib. > > > about making it a gem/plugin, I''d only do it if it''s going to be > > something really generic that you are going to be reusing in several > > projects. If not, it''s not worth the overwork. > > > Regards, > > > javier ramirez > > > -- > > -------- > > Estamos de estreno... si necesitas llevar el control de tus gastos > > visitahttp://www.gastosgem.com!!Es gratis!! > > -- > Posted viahttp://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-/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 -~----------~----~----~----~------~----~------~--~---