Adding "environments" configuration option (issue #74) #108

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
5 participants

Adding "environments" configuration option to explicitly declare under which Rails environments AssetSync should be enabled.

  • This option defaults to ["production", "staging"]
  • This option can be overriden by setting the "enabled" option in the desired environment of the yaml file.
  • Other environments different from production and staging are disabled by default, unless explicitly declared otherwise.

This references: rumblelabs#74

dgilperez added some commits Sep 24, 2012

@dgilperez dgilperez Adding "environments" configuration option to explicitly declare unde…
…r which Rails environments AssetSync should be enabled.

- This option defaults to ["production", "staging"]
- This option can be overriden by setting the "enabled" option in the desired environment of the yaml file.
- Other environments different from production and staging are disabled by default, unless explicitly declared otherwise.
6317631
@dgilperez dgilperez reorder requires cfe8389

Well this is not working fully yet. Tests are green but when I use it within an environment I get an error:

RAILS_ENV=production rails s                     
=> Booting Thin
=> Rails 3.2.8 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/dgilperez/src/myproject/config/initializers/asset_sync.rb:4:in `<top (required)>': undefined method `configure' for AssetSync:Module (NoMethodError)
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `block in load'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/engine.rb:587:in `each'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/engine.rb:587:in `block in <class:Engine>'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/dgilperez/src/myproject/config/environment.rb:10:in `<top (required)>'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from /Users/dgilperez/src/myproject/config.ru:4:in `block in <main>'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
    from /Users/dgilperez/src/myproject/config.ru:1:in `new'
    from /Users/dgilperez/src/myproject/config.ru:1:in `<main>'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/commands/server.rb:46:in `app'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/commands/server.rb:70:in `start'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
    from /Users/dgilperez/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Ideas? (and sorry if this is too newbie)

Contributor

freerobby commented Nov 1, 2012

Huh. I'm seeing the same thing on my fork/feature. Forked from latest master.

** Execute environment
Connecting to database specified by database.yml
rake aborted!
undefined method `configure' for AssetSync:Module
/var/www/shareaholic_on_rails/releases/20121101161012/config/initializers/asset_sync.rb:2:in `(root)'
org/jruby/RubyKernel.java:1068:in `load'
/var/www/shareaholic_on_rails/releases/20121101161012/config/initializers/asset_sync.rb:245:in `load'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/railties-3.2.8/lib/rails/engine.rb:588:in `Engine'
org/jruby/RubyArray.java:1615:in `each'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/railties-3.2.8/lib/rails/engine.rb:587:in `Engine'
org/jruby/RubyBasicObject.java:1757:in `instance_exec'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `run_initializers'
org/jruby/RubyArray.java:1615:in `each'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
/var/www/shareaholic_on_rails/releases/20121101161012/config/environment.rb:5:in `(root)'
org/jruby/RubyKernel.java:1042:in `require'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
/var/www/shareaholic_on_rails/releases/20121101161012/config/environment.rb:103:in `require_environment!'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/railties-3.2.8/lib/rails/application.rb:295:in `initialize_tasks'
org/jruby/RubyProc.java:258:in `call'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
org/jruby/RubyArray.java:1615:in `each'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/opt/torquebox/current/jruby/lib/ruby/1.9/monitor.rb:201:in `mon_synchronize'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `invoke_prerequisites'
org/jruby/RubyArray.java:1615:in `each'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `invoke_with_call_chain'
/opt/torquebox/current/jruby/lib/ruby/1.9/monitor.rb:201:in `mon_synchronize'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
org/jruby/RubyArray.java:1615:in `each'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/gems/rake-0.9.2.2/bin/rake:33:in `(root)'
org/jruby/RubyKernel.java:1068:in `load'
/var/www/shareaholic_on_rails/releases/20121101161012/vendor/bundle/jruby/1.9/bin/rake:23:in `(root)'
Contributor

freerobby commented Nov 1, 2012

I'm seeing this from asset_sync in master as well.

Contributor

freerobby commented Nov 1, 2012

If you move gem "asset_sync" from the :assets group of your Gemfile into a top-level dependency, this should work. Obviously you don't want to do that long-term, but doing so might help you pinpoint what in your production/test/dev environment is calling asset_sync. It could be your initializer.

Contributor

davidjrice commented Nov 1, 2012

@dgilperez @freerobby regarding undefined method configure this isn't a bug with asset_sync.

This is down to how bundler and the rails initialization process works.

As described in the installation instructions. You need to wrap the custom initializer if you choose to put asset_sync within your :assets group. https://github.com/rumblelabs/asset_sync#installation

Contributor

freerobby commented Nov 1, 2012

@davidjrice Agreed. I was just trying to figure out why v0.5 worked fine but master/HEAD did not.

Contributor

davidjrice commented Nov 1, 2012

@freerobby hmm. You sure? There shouldn't be a difference between 0.5 and master on this.

Anything I can do to help get this PR merged in? Is there any work remaining?

connec commented Mar 1, 2013

I'm getting this error too, which is strange because I do have the if defined? wrapper. It seems that module AssetSync is being defined somewhere, but without the configure method, even when bundler should ignore the gem?

As a workaround I'm now using if defined?(AssetSync) && AssetSync.respond_to?(:configure).

dgilperez closed this Aug 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment