Forum: Ruby on Rails help on building a plugin

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
E98de78bb42013c488fe8aa9d77d2cb1?d=identicon&s=25 unknown (Guest)
on 2007-02-13 16:27
(Received via mailing list)

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 <
      def initialize(bucket, cache_directory)
        @aws_access_key = 'YOURAWSACCESSKEY'         # your AWS ACCESS
        @aws_secret_access_key = 'YOURAWSSECRETKEY'  # your SECRET
        @bucket = bucket


In my config/environments/development.rb file I add the following
config.action_controller.fragment_cache_store ="quizical", "cache")

The problem is now when I start my server, I get the following error

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?

ps. check it out at 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
B8dbb1987e8e5318584865f880036796?d=identicon&s=25 Chris Wanstrath (defunkt)
on 2007-02-14 02:28
(Received via mailing list)
On 2/13/07, <> 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:


Shortcut: in config/environments/development.rb put:

config.after_initialize do
  config.action_controller.fragment_cache_store ="quizical", "cache")

Chris Wanstrath
E98de78bb42013c488fe8aa9d77d2cb1?d=identicon&s=25 unknown (Guest)
on 2007-02-14 05:55
(Received via mailing list)
Doh! Of course. Thanks Chris. That was what I needed.
This topic is locked and can not be replied to.