Thanks guys, just learnt another "Ruby way" of doing stuff, you helped a lot!
Arailsdemo: "chunk" is a much better fitting name for what I'm planning to implement, thanks for this.
Thanks guys, just learnt another "Ruby way" of doing stuff, you helped a lot!
Arailsdemo: "chunk" is a much better fitting name for what I'm planning to implement, thanks for this.
If you haven't worked with the lib/ directory before, make sure you have
config.autoload_paths += %W(#{config.root}/lib)
in config/application.rb
Also, if you ever want to make yourself a gem, you could do something like
# lib/acts_as_chunky_time
module ActsAsChunkyTime
def self.included(class_thats_including_my_module) class_thats_including_my_module.extend ClassMethods end
module ClassMethods def acts_as_chunky_time include ActsAsChunkyTime::InstanceMethods end end
module InstanceMethods def set_start_time ... def set_end_time ... def get_time_blocks ... end end
ActiveRecord::Base.send(:include, ActsAsChunkyTime)
# my_model.rb
class MyModel < AR::Base acts_as_chunky_time end
Manuel Kiessling wrote in post #974620:
Arailsdemo A. wrote in post #974689:
If you haven't worked with the lib/ directory before, make sure you have
config.autoload_paths += %W(#{config.root}/lib)
in config/application.rb
Or not. You can also require your lib files explicitly if you'd rather, though autoloading is *very* convenient.
Best,