steve.odom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-13 15:25 UTC
help on building a plugin
Hi,
I''ve developed some code that allows you to use s3 as a cache store
(ie store your cache fragments at s3 instead of your web server).
It works great when I have the code in my lib/ folder.
Now I want to package it as a plugin. i''m stuck.
My plugin directory is structured:
- s3cache
-- init.rb
-- lib/
----- s3_cache.rb
----- s3.rb
My init.rb file is this:
require ''s3_cache''
My lib/s3_cache file begins with:
require ''S3''
class S3Cache <
ActionController::Caching::Fragments::UnthreadedFileStore
def initialize(bucket, cache_directory)
@aws_access_key = ''YOURAWSACCESSKEY'' # your
AWS ACCESS
KEY
@aws_secret_access_key = ''YOURAWSSECRETKEY'' # your
SECRET
@bucket = bucket
<snip>
------------
In my config/environments/development.rb file I add the following
line:
config.action_controller.fragment_cache_store S3Cache.new("quizical",
"cache")
-------------
The problem is now when I start my server, I get the following error
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/
active_support/dependencies.rb:123:in `const_missing'': uninitialized
constant S3Cache (NameError)
--------------
Everything works fine if I put s3_cache.rb and s3.rb in my lib/
folder. But I seem to be missing something in init.rb of my plugin or
have something else structured wrong.
any ideas?
Steve
http://niblets.wordpress.com
ps. check it out at www.quizical.net and see if you can tell speed-
wise that I''m storing cache fragments at s3. I''m also serving
up all
of my public directory from s3 too - essentially using it as my asset
server.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
On 2/13/07, steve.odom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <steve.odom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The problem is now when I start my server, I get the following errorPlugins are loaded *after* the environment is loaded. Subscribe to Rick Olson''s blog and read these entries: http://weblog.techno-weenie.net/2007/1/24/understanding-the-rails-initialization-process then http://weblog.techno-weenie.net/2007/1/25/understanding-the-rails-initialization-process-part-2 Shortcut: in config/environments/development.rb put: config.after_initialize do config.action_controller.fragment_cache_store S3Cache.new("quizical", "cache") end -- Chris Wanstrath http://errtheblog.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 -~----------~----~----~----~------~----~------~--~---
steve.odom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-14 04:55 UTC
Re: help on building a plugin
Doh! Of course. Thanks Chris. That was what I needed. On Feb 13, 7:27 pm, "Chris Wanstrath" <c...-G5sj8e7vJc8@public.gmane.org> wrote:> On 2/13/07, steve.o...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <steve.o...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > The problem is now when I start my server, I get the following error > > Plugins are loaded *after* the environment is loaded. Subscribe to > Rick Olson''s blog and read these entries:http://weblog.techno-weenie.net/2007/1/24/understanding-the-rails-ini... > > then > > http://weblog.techno-weenie.net/2007/1/25/understanding-the-rails-ini... > > Shortcut: in config/environments/development.rb put: > > config.after_initialize do > config.action_controller.fragment_cache_store > S3Cache.new("quizical", "cache") > end > > -- > Chris Wanstrathhttp://errtheblog.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 -~----------~----~----~----~------~----~------~--~---