Hello, I''m trying to use some methods I''m defining in a module in a model and my rake task. How can I do this? Any help would be appreciated. I''ve currently got the following, but my rake task can''t access the methods in my module. Instead, I get.. undefined local variable or method `report_csv_process'' for #<Object:0x284f9e8> /lib/module/order_process module order_process def process_order(id) #do stuff end /lib/tasks/ordering.rake include order_process namespace :send_report do task :order => :environment do process_order(id) end end /app/models/segment.rb class Segment < ActiveRecord::Base include report_csv_process bla bla end -- 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 -~----------~----~----~----~------~----~------~--~---
I was a little off, but still haven''t quite figured it out. I currently have:> /lib/module/order_process.rb > module order_process > def process_order(id) > #do stuff > end > > > /lib/tasks/ordering.rake > > include ''order_process.rb'' > namespace :send_report do > task :order => :environment do > process_order(id) > end > end > > /app/models/segment.rb > class Segment < ActiveRecord::Base > include ''report_csv_process.rb'' > > bla bla > > endI tried removing the single quotes, without luck -- 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 -~----------~----~----~----~------~----~------~--~---
Did you ever figure out how this is done? I''m stuck on the exact problem (trying to use some custom module code inside a rake task). On Apr 15, 8:06 pm, Mario Gr <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I was a little off, but still haven''t quite figured it out. I currently > have: > > > > > /lib/module/order_process.rb > >moduleorder_process > > def process_order(id) > > #do stuff > > end > > > /lib/tasks/ordering.rake > > > include ''order_process.rb'' > > namespace :send_report do > > task:order => :environment do > > process_order(id) > > end > > end > > > /app/models/segment.rb > > class Segment < ActiveRecord::Base > > include ''report_csv_process.rb'' > > > bla bla > > > end > > I tried removing the single quotes, without luck > -- > Posted viahttp://www.ruby-forum.com/.
Yep. I had to both require the file then include the module: require ''lib/modules/report_csv_process.rb'' include ReportCsvProcess -- Posted via http://www.ruby-forum.com/.
Hu? Did you not read my last post? You wrote almost exactly the same questing twice. You have to both require the file, then include the module. ###rake_file.rb require ''lib/modules/your_module_filename.rb'' namespace :your_rake_task do include your_module_name #do stuff end -- Posted via http://www.ruby-forum.com/.