Re: [Rails-core] Making touch more efficient

2012-09-28 Thread Spike
Thanks Matt, sorry I missed this reply. Bummer I'm still on 2.3, will have to get moving on the upgrade :D Cheers, Brendon On Friday, June 8, 2012 12:30:02 PM UTC+12, Matt jones wrote: On Jun 7, 2012, at 6:55 PM, Spike wrote: I'm currently working on a Rails 2.3 project but I think the

[Rails-core] Overring methods on engines

2012-09-28 Thread Luís Ferreira
Hey guys, I've been working on engines lately and I can't understand why a class in an engine can't be monkey patched. Here's an example: In the engine: class MyEngine::MyController ApplicationController def index @stuff = 1 end def show ... something happens ... end end In

Re: [Rails-core] Overring methods on engines

2012-09-28 Thread Robert Pankowecki
Probably because of the way how Rails is looking for constants ? I would guess that it does not read the file from engine at all, and just reads the file from your app. Robert Pankowecki http://robert.pankowecki.pl On Fri, Sep 28, 2012 at 12:59 PM, Luís Ferreira zamith...@gmail.com wrote: Hey

Re: [Rails-core] Overring methods on engines

2012-09-28 Thread Luís Ferreira
Hum... Haven't thought of that. Thanks. Still, this is not the expected behaviour for a ruby class right? Or am I completly wrong here? On Sep 28, 2012, at 12:02 PM, Robert Pankowecki wrote: Probably because of the way how Rails is looking for constants ? I would guess that it does not read

Re: [Rails-core] Overring methods on engines

2012-09-28 Thread Luís Ferreira
Also, even if I change the load order of the app and engine and load the engine first the same thing happens. This way the engine's file has already been loaded and then it is completly overriden. Maybe I'm missing something here, but this is the behavior I have experienced. On Sep 28, 2012,

Re: [Rails-core] Overring methods on engines

2012-09-28 Thread Godfrey Chan
If you are using Rails 3.2, you can tell Rails to load your engine before it loads your app like so: config.railties_order = [ Your::Engine, :main_app, :all ] Then your monkey patching should work. If you are on older versions of Rails you can monkey patch AS::Dependencies like

Re: [Rails-core] Overring methods on engines

2012-09-28 Thread Ken Collins
I just clicked thru those slides the other day too. Having developed engines locally bundled to other applications, the part he talks about continuous development, is a dream. I found that in Bundler 1.2 you can config a repo for local usage without changing the Gemfile too.

Re: [Rails-core] Overring methods on engines

2012-09-28 Thread Godfrey Chan
Also, you might want to use class_eval for monkey patching. This way it errors out if the original implementation has not been loaded yet, so you'll know something has gone wrong. See here - http://practicalruby.blogspot.com/2007/02/reopen-with-moduleeval.html Godfrey On 2012-09-28, at 4:20

Re: [Rails-core] Overring methods on engines

2012-09-28 Thread Luís Ferreira
Thanks for the quick response. As I've said, even if I change the loading order it still won't work. I'll try class_eval but still I don't understand why the monkey patching does not work. Is it a feature of the engine that it has an all or nothing overriding of classes? On Sep 28, 2012, at

[Rails-core] Overriding class_attribute writers and order of super/extend C.M./included block eval in ActiveSupport::Concern

2012-09-28 Thread Gary Weaver
I have: module MySpike extend ActiveSupport::Concern included do class_attribute :foobar, instance_writer: true end end But, I want to be able to override the class attribute writer and/or instance writer method to do something when the attribute is set via self.foobar = true