charlie bowman
2006-Apr-11 23:37 UTC
[Rails] I can''t get rails to see my plugin. How can I this?
I''m trying to produce a plugin to help me with my page caching woes. I can''t seem to get rails to see my method within the plugin. This is my first attempt at a plugin so I''m sure I''m missing something. I''ve created a directory /vendor/lib/plugins/broom_stick/. I then created an init.rb file with: require ''broom_stick'' I then created /vendor/lib/plugins/broom_stick/lib/broom_stick.rb Here are the contents of broom_stick.rb. It doesn''t add any new functionalit...yet. I wanted to make sure I could get the plugin seen by rails before I did any real coding. Thanks in advance for any assistance. module ActionController::Caching::Pages::ClassMethods # Expires the page that was cached with the +path+ as a key. Example: # expire_page "/lists/show" def expire_each_page(path) return unless perform_caching benchmaddrk "EXPIRED ALL PAGES: #{page_cache_file(path)}" do File.delete(page_cache_path(path)) if File.exists?(page_cache_path(path)) Dir.foreach(page_cache_path(path)) {|x| benchmark ("Got " + x) } end end end -- Posted via http://www.ruby-forum.com/.
Ray Baxter
2006-Apr-12 04:10 UTC
[Rails] Re: I can''t get rails to see my plugin. How can I this?
charlie bowman wrote:> I''m trying to produce a plugin to help me with my page caching woes. I > can''t seem to get rails to see my method within the plugin. This is my > first attempt at a plugin so I''m sure I''m missing something. I''ve > created a directory /vendor/lib/plugins/broom_stick/. I then created anThe simplest possible thing, you do mean: #{RAILS_ROOT}/vendor/lib/plugins/broom_stick/ right? -- Ray
Trevor Squires
2006-Apr-12 04:33 UTC
[Rails] I can''t get rails to see my plugin. How can I this?
On 11-Apr-06, at 4:36 PM, charlie bowman wrote:> I''m trying to produce a plugin to help me with my page caching > woes. I > can''t seem to get rails to see my method within the plugin. This > is my > first attempt at a plugin so I''m sure I''m missing something. I''ve > created a directory /vendor/lib/plugins/broom_stick/. I then > created an > init.rb file with: > require ''broom_stick'' >Hi Charlie, I think your folder hierarchy is wrong: vendor/plugins/broom_stick/init.rb vendor/plugins/broom_stick/lib/broom_stick.rb If you''ve got any doubt, the simplest thing to do is use the plugin generator to see how to properly layout a plugin: (in your rails application root) ./script/generate plugin test_this will show you where the files ought to go (you can remove vendor/ plugins/test_this afterwards). Regards, Trevor -- Trevor Squires http://somethinglearned.com
Charlie Bowman
2006-Apr-12 12:41 UTC
[Rails] I can''t get rails to see my plugin. How can I this?
Actually, the path was a typo. I am using the path: /vendor/plugins/broom_stick/. On Tue, 2006-04-11 at 21:33 -0700, Trevor Squires wrote:> On 11-Apr-06, at 4:36 PM, charlie bowman wrote: > > > I''m trying to produce a plugin to help me with my page caching > > woes. I > > can''t seem to get rails to see my method within the plugin. This > > is my > > first attempt at a plugin so I''m sure I''m missing something. I''ve > > created a directory /vendor/lib/plugins/broom_stick/. I then > > created an > > init.rb file with: > > require ''broom_stick'' > > > > Hi Charlie, > > I think your folder hierarchy is wrong: > > vendor/plugins/broom_stick/init.rb > vendor/plugins/broom_stick/lib/broom_stick.rb > > If you''ve got any doubt, the simplest thing to do is use the plugin > generator to see how to properly layout a plugin: > > (in your rails application root) > > ./script/generate plugin test_this > > will show you where the files ought to go (you can remove vendor/ > plugins/test_this afterwards). > > Regards, > Trevor > -- > Trevor Squires > http://somethinglearned.com > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/f1094024/attachment-0001.html
Trevor Squires
2006-Apr-12 15:16 UTC
[Rails] I can''t get rails to see my plugin. How can I this?
Hi again Charlie, you''ve got me wondering - you *do* realize that you''ve only added your method to the ClassMethods module (so it''s not a controller instance method) right? So you have to use it like: MyController.expire_each_page(somepath) The code you posted really ought to work so trying to call a class method as though it was an instance method is about the only place I can think you''re going wrong. HTH, Trevor -- Trevor Squires http://somethinglearned.com On 12-Apr-06, at 5:41 AM, Charlie Bowman wrote:> Actually, the path was a typo. I am using the path: /vendor/ > plugins/broom_stick/. > > On Tue, 2006-04-11 at 21:33 -0700, Trevor Squires wrote: >> On 11-Apr-06, at 4:36 PM, charlie bowman wrote: >> >> > I''m trying to produce a plugin to help me with my page caching >> > woes. I >> > can''t seem to get rails to see my method within the plugin. This >> > is my >> > first attempt at a plugin so I''m sure I''m missing something. I''ve >> > created a directory /vendor/lib/plugins/broom_stick/. I then >> > created an >> > init.rb file with: >> > require ''broom_stick'' >> > >> >> Hi Charlie, >> >> I think your folder hierarchy is wrong: >> >> vendor/plugins/broom_stick/init.rb >> vendor/plugins/broom_stick/lib/broom_stick.rb >> >> If you''ve got any doubt, the simplest thing to do is use the plugin >> generator to see how to properly layout a plugin: >> >> (in your rails application root) >> >> ./script/generate plugin test_this >> >> will show you where the files ought to go (you can remove vendor/ >> plugins/test_this afterwards). >> >> Regards, >> Trevor >> -- >> Trevor Squires >> http://somethinglearned.com >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/cba3c09c/attachment.html
Charlie Bowman
2006-Apr-12 15:43 UTC
[Rails] I can''t get rails to see my plugin. How can I this?
I didn''t. I''m still trying hard to grasp the inner working of rails and ruby inheritance in general. I have modified the plugin but it is still breaking because it can''t find the page_cache_path and page_cache_file methods. Here''s what I''ve got so far. Thank you for your help so far! module ActionController::Caching::Pages def expire_each_page(path) return unless perform_caching logger.error("EXPIRED ALL PAGES: #{path}") File.delete(page_cache_path(path)) if File.exists?(page_cache_path(path)) Dir.foreach(page_cache_path(path)) {|x| benchmark ("Got " + x) } rescue end end On Wed, 2006-04-12 at 08:16 -0700, Trevor Squires wrote:> Hi again Charlie, > > > you''ve got me wondering - you *do* realize that you''ve only added your > method to the ClassMethods module (so it''s not a controller instance > method) right? > > > So you have to use it like: > > > MyController.expire_each_page(somepath) > > > The code you posted really ought to work so trying to call a class > method as though it was an instance method is about the only place I > can think you''re going wrong. > > > HTH, > Trevor > > -- > Trevor Squires > http://somethinglearned.com > > > > On 12-Apr-06, at 5:41 AM, Charlie Bowman wrote: > > > Actually, the path was a typo. I am using the > > path: /vendor/plugins/broom_stick/. > > > > On Tue, 2006-04-11 at 21:33 -0700, Trevor Squires wrote: > > > On 11-Apr-06, at 4:36 PM, charlie bowman wrote: > > > > > > > I''m trying to produce a plugin to help me with my page caching > > > > woes. I > > > > can''t seem to get rails to see my method within the plugin. This > > > > is my > > > > first attempt at a plugin so I''m sure I''m missing something. I''ve > > > > created a directory /vendor/lib/plugins/broom_stick/. I then > > > > created an > > > > init.rb file with: > > > > require ''broom_stick'' > > > > > > > > > > Hi Charlie, > > > > > > I think your folder hierarchy is wrong: > > > > > > vendor/plugins/broom_stick/init.rb > > > vendor/plugins/broom_stick/lib/broom_stick.rb > > > > > > If you''ve got any doubt, the simplest thing to do is use the plugin > > > generator to see how to properly layout a plugin: > > > > > > (in your rails application root) > > > > > > ./script/generate plugin test_this > > > > > > will show you where the files ought to go (you can remove vendor/ > > > plugins/test_this afterwards). > > > > > > Regards, > > > Trevor > > > -- > > > Trevor Squires > > > http://somethinglearned.com > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Trevor Squires
2006-Apr-12 16:00 UTC
[Rails] I can''t get rails to see my plugin. How can I this?
Hey again, you can''t find page_cache_path and page_cache_file because they are *class* methods. With the changes you sent your expire_each_page method is now an *instance* method (it''s no longer in the ClassMethods module). So, change the calls to page_cache_path and page_cache_file to be self.class.page_cache_path and self.class.page_cache_file and see how you get on. Regards, Trevor -- Trevor Squires http://somethinglearned.com On 12-Apr-06, at 8:43 AM, Charlie Bowman wrote:> I didn''t. I''m still trying hard to grasp the inner working of > rails and > ruby inheritance in general. I have modified the plugin but it is > still > breaking because it can''t find the page_cache_path and page_cache_file > methods. Here''s what I''ve got so far. Thank you for your help so > far! > > module ActionController::Caching::Pages > def expire_each_page(path) > return unless perform_caching > logger.error("EXPIRED ALL PAGES: #{path}") > File.delete(page_cache_path(path)) if > File.exists?(page_cache_path(path)) > Dir.foreach(page_cache_path(path)) {|x| benchmark ("Got " + x) } > rescue > end > end > > > > On Wed, 2006-04-12 at 08:16 -0700, Trevor Squires wrote: >> Hi again Charlie, >> >> >> you''ve got me wondering - you *do* realize that you''ve only added >> your >> method to the ClassMethods module (so it''s not a controller instance >> method) right? >> >> >> So you have to use it like: >> >> >> MyController.expire_each_page(somepath) >> >> >> The code you posted really ought to work so trying to call a class >> method as though it was an instance method is about the only place I >> can think you''re going wrong. >> >> >> HTH, >> Trevor >> >> -- >> Trevor Squires >> http://somethinglearned.com >> >> >> >> On 12-Apr-06, at 5:41 AM, Charlie Bowman wrote: >> >>> Actually, the path was a typo. I am using the >>> path: /vendor/plugins/broom_stick/. >>> >>> On Tue, 2006-04-11 at 21:33 -0700, Trevor Squires wrote: >>>> On 11-Apr-06, at 4:36 PM, charlie bowman wrote: >>>> >>>>> I''m trying to produce a plugin to help me with my page caching >>>>> woes. I >>>>> can''t seem to get rails to see my method within the plugin. This >>>>> is my >>>>> first attempt at a plugin so I''m sure I''m missing something. I''ve >>>>> created a directory /vendor/lib/plugins/broom_stick/. I then >>>>> created an >>>>> init.rb file with: >>>>> require ''broom_stick'' >>>>> >>>> >>>> Hi Charlie, >>>> >>>> I think your folder hierarchy is wrong: >>>> >>>> vendor/plugins/broom_stick/init.rb >>>> vendor/plugins/broom_stick/lib/broom_stick.rb >>>> >>>> If you''ve got any doubt, the simplest thing to do is use the plugin >>>> generator to see how to properly layout a plugin: >>>> >>>> (in your rails application root) >>>> >>>> ./script/generate plugin test_this >>>> >>>> will show you where the files ought to go (you can remove vendor/ >>>> plugins/test_this afterwards). >>>> >>>> Regards, >>>> Trevor >>>> -- >>>> Trevor Squires >>>> http://somethinglearned.com >>>> >>>> _______________________________________________ >>>> Rails mailing list >>>> Rails@lists.rubyonrails.org >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>> >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails@lists.rubyonrails.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Trevor Squires
2006-Apr-12 17:30 UTC
[Rails] I can''t get rails to see my plugin. How can I this?
Hi Charlie, it would seem on my last email I steered you a bit wrong: namely I forgot that page_cache_file and page_cache_path are private class methods so you can''t call them from an instance method. Try this instead: module ActionController::Caching::Pages module ClassMethods def expire_each_page(path) return unless perform_caching logger.error("EXPIRED ALL PAGES: #{path}") File.delete(page_cache_path(path)) if File.exists? (page_cache_path(path)) Dir.foreach(page_cache_path(path)) {|x| benchmark ("Got " + x) } rescue end end def expire_each_page(path) self.class.expire_each_page(path) end end Regards, Trevor -- Trevor Squires http://somethinglearned.com On 12-Apr-06, at 8:43 AM, Charlie Bowman wrote:> I didn''t. I''m still trying hard to grasp the inner working of > rails and > ruby inheritance in general. I have modified the plugin but it is > still > breaking because it can''t find the page_cache_path and page_cache_file > methods. Here''s what I''ve got so far. Thank you for your help so > far! > > module ActionController::Caching::Pages > def expire_each_page(path) > return unless perform_caching > logger.error("EXPIRED ALL PAGES: #{path}") > File.delete(page_cache_path(path)) if > File.exists?(page_cache_path(path)) > Dir.foreach(page_cache_path(path)) {|x| benchmark ("Got " + x) } > rescue > end > end > > > > On Wed, 2006-04-12 at 08:16 -0700, Trevor Squires wrote: >> Hi again Charlie, >> >> >> you''ve got me wondering - you *do* realize that you''ve only added >> your >> method to the ClassMethods module (so it''s not a controller instance >> method) right? >> >> >> So you have to use it like: >> >> >> MyController.expire_each_page(somepath) >> >> >> The code you posted really ought to work so trying to call a class >> method as though it was an instance method is about the only place I >> can think you''re going wrong. >> >> >> HTH, >> Trevor >> >> -- >> Trevor Squires >> http://somethinglearned.com >> >> >> >> On 12-Apr-06, at 5:41 AM, Charlie Bowman wrote: >> >>> Actually, the path was a typo. I am using the >>> path: /vendor/plugins/broom_stick/. >>> >>> On Tue, 2006-04-11 at 21:33 -0700, Trevor Squires wrote: >>>> On 11-Apr-06, at 4:36 PM, charlie bowman wrote: >>>> >>>>> I''m trying to produce a plugin to help me with my page caching >>>>> woes. I >>>>> can''t seem to get rails to see my method within the plugin. This >>>>> is my >>>>> first attempt at a plugin so I''m sure I''m missing something. I''ve >>>>> created a directory /vendor/lib/plugins/broom_stick/. I then >>>>> created an >>>>> init.rb file with: >>>>> require ''broom_stick'' >>>>> >>>> >>>> Hi Charlie, >>>> >>>> I think your folder hierarchy is wrong: >>>> >>>> vendor/plugins/broom_stick/init.rb >>>> vendor/plugins/broom_stick/lib/broom_stick.rb >>>> >>>> If you''ve got any doubt, the simplest thing to do is use the plugin >>>> generator to see how to properly layout a plugin: >>>> >>>> (in your rails application root) >>>> >>>> ./script/generate plugin test_this >>>> >>>> will show you where the files ought to go (you can remove vendor/ >>>> plugins/test_this afterwards). >>>> >>>> Regards, >>>> Trevor >>>> -- >>>> Trevor Squires >>>> http://somethinglearned.com >>>> >>>> _______________________________________________ >>>> Rails mailing list >>>> Rails@lists.rubyonrails.org >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>> >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails@lists.rubyonrails.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Charlie Bowman
2006-Apr-12 17:32 UTC
[Rails] I can''t get rails to see my plugin. How can I this?
Thanks again for so much help! I think I''m getting much closer to understanding this stuff. It still isn''t quite there. The app runs and rails doesn''t complain about not finding the methods, but I still can''t get the correct result out of the method. Only the first logger.error is printing to the log. I added a two more logger statements and the second statement won''t print. I"m I missing something else as well? module ActionController::Caching::Pages # Expires the page that was cached with the +path+ as a key. Example: expire_page "/lists/show" def expire_each_page(path) return unless perform_caching #test = self.class.page_cache_path(path) logger.error("EXPIRED ALL PAGES: #{path}") test = self.class.page_cache_path(path) logger.error("FULL PATH OF PAGES: #{test}") File.delete(self.class.page_cache_path(path)) if File.exists?(self.class.page_cache_path(path)) Dir.foreach(self.class.page_cache_path(path)) {|x| logger.error("Got #{x}") } rescue end end On Wed, 2006-04-12 at 08:59 -0700, Trevor Squires wrote:> Hey again, > > you can''t find page_cache_path and page_cache_file because they are > *class* methods. > > With the changes you sent your expire_each_page method is now an > *instance* method (it''s no longer in the ClassMethods module). > > So, change the calls to page_cache_path and page_cache_file to be > self.class.page_cache_path and self.class.page_cache_file and see how > you get on. > > Regards, > Trevor > > -- > Trevor Squires > http://somethinglearned.com > > > > On 12-Apr-06, at 8:43 AM, Charlie Bowman wrote: > > > I didn''t. I''m still trying hard to grasp the inner working of > > rails and > > ruby inheritance in general. I have modified the plugin but it is > > still > > breaking because it can''t find the page_cache_path and page_cache_file > > methods. Here''s what I''ve got so far. Thank you for your help so > > far! > > > > module ActionController::Caching::Pages > > def expire_each_page(path) > > return unless perform_caching > > logger.error("EXPIRED ALL PAGES: #{path}") > > File.delete(page_cache_path(path)) if > > File.exists?(page_cache_path(path)) > > Dir.foreach(page_cache_path(path)) {|x| benchmark ("Got " + x) } > > rescue > > end > > end > > > > > > > > On Wed, 2006-04-12 at 08:16 -0700, Trevor Squires wrote: > >> Hi again Charlie, > >> > >> > >> you''ve got me wondering - you *do* realize that you''ve only added > >> your > >> method to the ClassMethods module (so it''s not a controller instance > >> method) right? > >> > >> > >> So you have to use it like: > >> > >> > >> MyController.expire_each_page(somepath) > >> > >> > >> The code you posted really ought to work so trying to call a class > >> method as though it was an instance method is about the only place I > >> can think you''re going wrong. > >> > >> > >> HTH, > >> Trevor > >> > >> -- > >> Trevor Squires > >> http://somethinglearned.com > >> > >> > >> > >> On 12-Apr-06, at 5:41 AM, Charlie Bowman wrote: > >> > >>> Actually, the path was a typo. I am using the > >>> path: /vendor/plugins/broom_stick/. > >>> > >>> On Tue, 2006-04-11 at 21:33 -0700, Trevor Squires wrote: > >>>> On 11-Apr-06, at 4:36 PM, charlie bowman wrote: > >>>> > >>>>> I''m trying to produce a plugin to help me with my page caching > >>>>> woes. I > >>>>> can''t seem to get rails to see my method within the plugin. This > >>>>> is my > >>>>> first attempt at a plugin so I''m sure I''m missing something. I''ve > >>>>> created a directory /vendor/lib/plugins/broom_stick/. I then > >>>>> created an > >>>>> init.rb file with: > >>>>> require ''broom_stick'' > >>>>> > >>>> > >>>> Hi Charlie, > >>>> > >>>> I think your folder hierarchy is wrong: > >>>> > >>>> vendor/plugins/broom_stick/init.rb > >>>> vendor/plugins/broom_stick/lib/broom_stick.rb > >>>> > >>>> If you''ve got any doubt, the simplest thing to do is use the plugin > >>>> generator to see how to properly layout a plugin: > >>>> > >>>> (in your rails application root) > >>>> > >>>> ./script/generate plugin test_this > >>>> > >>>> will show you where the files ought to go (you can remove vendor/ > >>>> plugins/test_this afterwards). > >>>> > >>>> Regards, > >>>> Trevor > >>>> -- > >>>> Trevor Squires > >>>> http://somethinglearned.com > >>>> > >>>> _______________________________________________ > >>>> Rails mailing list > >>>> Rails@lists.rubyonrails.org > >>>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>>> > >>> > >>> > >>> _______________________________________________ > >>> Rails mailing list > >>> Rails@lists.rubyonrails.org > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > >> _______________________________________________ > >> Rails mailing list > >> Rails@lists.rubyonrails.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Charlie Bowman
2006-Apr-12 17:36 UTC
[Rails] I can''t get rails to see my plugin. How can I this?
Thanks, I''ll give that I try! On Wed, 2006-04-12 at 10:30 -0700, Trevor Squires wrote:> Hi Charlie, > > it would seem on my last email I steered you a bit wrong: namely I > forgot that page_cache_file and page_cache_path are private class > methods so you can''t call them from an instance method. > > Try this instead: > > module ActionController::Caching::Pages > module ClassMethods > def expire_each_page(path) > return unless perform_caching > logger.error("EXPIRED ALL PAGES: #{path}") > File.delete(page_cache_path(path)) if File.exists? > (page_cache_path(path)) > Dir.foreach(page_cache_path(path)) {|x| benchmark ("Got " + x) } > rescue > end > end > > def expire_each_page(path) > self.class.expire_each_page(path) > end > end > > Regards, > Trevor > > -- > Trevor Squires > http://somethinglearned.com > > > > On 12-Apr-06, at 8:43 AM, Charlie Bowman wrote: > > > I didn''t. I''m still trying hard to grasp the inner working of > > rails and > > ruby inheritance in general. I have modified the plugin but it is > > still > > breaking because it can''t find the page_cache_path and page_cache_file > > methods. Here''s what I''ve got so far. Thank you for your help so > > far! > > > > module ActionController::Caching::Pages > > def expire_each_page(path) > > return unless perform_caching > > logger.error("EXPIRED ALL PAGES: #{path}") > > File.delete(page_cache_path(path)) if > > File.exists?(page_cache_path(path)) > > Dir.foreach(page_cache_path(path)) {|x| benchmark ("Got " + x) } > > rescue > > end > > end > > > > > > > > On Wed, 2006-04-12 at 08:16 -0700, Trevor Squires wrote: > >> Hi again Charlie, > >> > >> > >> you''ve got me wondering - you *do* realize that you''ve only added > >> your > >> method to the ClassMethods module (so it''s not a controller instance > >> method) right? > >> > >> > >> So you have to use it like: > >> > >> > >> MyController.expire_each_page(somepath) > >> > >> > >> The code you posted really ought to work so trying to call a class > >> method as though it was an instance method is about the only place I > >> can think you''re going wrong. > >> > >> > >> HTH, > >> Trevor > >> > >> -- > >> Trevor Squires > >> http://somethinglearned.com > >> > >> > >> > >> On 12-Apr-06, at 5:41 AM, Charlie Bowman wrote: > >> > >>> Actually, the path was a typo. I am using the > >>> path: /vendor/plugins/broom_stick/. > >>> > >>> On Tue, 2006-04-11 at 21:33 -0700, Trevor Squires wrote: > >>>> On 11-Apr-06, at 4:36 PM, charlie bowman wrote: > >>>> > >>>>> I''m trying to produce a plugin to help me with my page caching > >>>>> woes. I > >>>>> can''t seem to get rails to see my method within the plugin. This > >>>>> is my > >>>>> first attempt at a plugin so I''m sure I''m missing something. I''ve > >>>>> created a directory /vendor/lib/plugins/broom_stick/. I then > >>>>> created an > >>>>> init.rb file with: > >>>>> require ''broom_stick'' > >>>>> > >>>> > >>>> Hi Charlie, > >>>> > >>>> I think your folder hierarchy is wrong: > >>>> > >>>> vendor/plugins/broom_stick/init.rb > >>>> vendor/plugins/broom_stick/lib/broom_stick.rb > >>>> > >>>> If you''ve got any doubt, the simplest thing to do is use the plugin > >>>> generator to see how to properly layout a plugin: > >>>> > >>>> (in your rails application root) > >>>> > >>>> ./script/generate plugin test_this > >>>> > >>>> will show you where the files ought to go (you can remove vendor/ > >>>> plugins/test_this afterwards). > >>>> > >>>> Regards, > >>>> Trevor > >>>> -- > >>>> Trevor Squires > >>>> http://somethinglearned.com > >>>> > >>>> _______________________________________________ > >>>> Rails mailing list > >>>> Rails@lists.rubyonrails.org > >>>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>>> > >>> > >>> > >>> _______________________________________________ > >>> Rails mailing list > >>> Rails@lists.rubyonrails.org > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > >> _______________________________________________ > >> Rails mailing list > >> Rails@lists.rubyonrails.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/ec7bf81e/attachment-0001.html
Charlie Bowman
2006-Apr-12 17:51 UTC
[Rails] I can''t get rails to see my plugin. How can I this?
Thanks, your last tip really helped out! My method ran correctly. So just to make sure I have this correct in my head, I''m adding a method to the ClassMethods module. Then I''m creating a method of the same name in ActionController::Caching::Pages. This second method calls the method in the module ClassMethods? Wow this stuff can be confusing! On Wed, 2006-04-12 at 10:30 -0700, Trevor Squires wrote:> Hi Charlie, > > it would seem on my last email I steered you a bit wrong: namely I > forgot that page_cache_file and page_cache_path are private class > methods so you can''t call them from an instance method. > > Try this instead: > > module ActionController::Caching::Pages > module ClassMethods > def expire_each_page(path) > return unless perform_caching > logger.error("EXPIRED ALL PAGES: #{path}") > File.delete(page_cache_path(path)) if File.exists? > (page_cache_path(path)) > Dir.foreach(page_cache_path(path)) {|x| benchmark ("Got " + x) } > rescue > end > end > > def expire_each_page(path) > self.class.expire_each_page(path) > end > end > > Regards, > Trevor > > -- > Trevor Squires > http://somethinglearned.com > > > > On 12-Apr-06, at 8:43 AM, Charlie Bowman wrote: > > > I didn''t. I''m still trying hard to grasp the inner working of > > rails and > > ruby inheritance in general. I have modified the plugin but it is > > still > > breaking because it can''t find the page_cache_path and page_cache_file > > methods. Here''s what I''ve got so far. Thank you for your help so > > far! > > > > module ActionController::Caching::Pages > > def expire_each_page(path) > > return unless perform_caching > > logger.error("EXPIRED ALL PAGES: #{path}") > > File.delete(page_cache_path(path)) if > > File.exists?(page_cache_path(path)) > > Dir.foreach(page_cache_path(path)) {|x| benchmark ("Got " + x) } > > rescue > > end > > end > > > > > > > > On Wed, 2006-04-12 at 08:16 -0700, Trevor Squires wrote: > >> Hi again Charlie, > >> > >> > >> you''ve got me wondering - you *do* realize that you''ve only added > >> your > >> method to the ClassMethods module (so it''s not a controller instance > >> method) right? > >> > >> > >> So you have to use it like: > >> > >> > >> MyController.expire_each_page(somepath) > >> > >> > >> The code you posted really ought to work so trying to call a class > >> method as though it was an instance method is about the only place I > >> can think you''re going wrong. > >> > >> > >> HTH, > >> Trevor > >> > >> -- > >> Trevor Squires > >> http://somethinglearned.com > >> > >> > >> > >> On 12-Apr-06, at 5:41 AM, Charlie Bowman wrote: > >> > >>> Actually, the path was a typo. I am using the > >>> path: /vendor/plugins/broom_stick/. > >>> > >>> On Tue, 2006-04-11 at 21:33 -0700, Trevor Squires wrote: > >>>> On 11-Apr-06, at 4:36 PM, charlie bowman wrote: > >>>> > >>>>> I''m trying to produce a plugin to help me with my page caching > >>>>> woes. I > >>>>> can''t seem to get rails to see my method within the plugin. This > >>>>> is my > >>>>> first attempt at a plugin so I''m sure I''m missing something. I''ve > >>>>> created a directory /vendor/lib/plugins/broom_stick/. I then > >>>>> created an > >>>>> init.rb file with: > >>>>> require ''broom_stick'' > >>>>> > >>>> > >>>> Hi Charlie, > >>>> > >>>> I think your folder hierarchy is wrong: > >>>> > >>>> vendor/plugins/broom_stick/init.rb > >>>> vendor/plugins/broom_stick/lib/broom_stick.rb > >>>> > >>>> If you''ve got any doubt, the simplest thing to do is use the plugin > >>>> generator to see how to properly layout a plugin: > >>>> > >>>> (in your rails application root) > >>>> > >>>> ./script/generate plugin test_this > >>>> > >>>> will show you where the files ought to go (you can remove vendor/ > >>>> plugins/test_this afterwards). > >>>> > >>>> Regards, > >>>> Trevor > >>>> -- > >>>> Trevor Squires > >>>> http://somethinglearned.com > >>>> > >>>> _______________________________________________ > >>>> Rails mailing list > >>>> Rails@lists.rubyonrails.org > >>>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>>> > >>> > >>> > >>> _______________________________________________ > >>> Rails mailing list > >>> Rails@lists.rubyonrails.org > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > >> _______________________________________________ > >> Rails mailing list > >> Rails@lists.rubyonrails.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/bcdda65a/attachment.html
Trevor Squires
2006-Apr-12 22:12 UTC
[Rails] I can''t get rails to see my plugin. How can I this?
On 12-Apr-06, at 10:51 AM, Charlie Bowman wrote:> Thanks, your last tip really helped out! My method ran correctly. > So just to make sure I have this correct in my head, I''m adding a > method to the ClassMethods module. Then I''m creating a method of > the same name in ActionController::Caching::Pages. This second > method calls the method in the module ClassMethods? Wow this stuff > can be confusing! >That''s about the size of it. Regards, Trevor -- Trevor Squires http://somethinglearned.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/ba1679bd/attachment.html