resolve/refinerycms — Issue #1149: Plugins not working in Rails 3.1?
Author: mabounassif
Created: 2011-11-25 05:23:27+00:00
State: open

I have built a normal refinery application, and everything is working just fine. However, when I try to generate a new plugin using the:

rails g refinery:engine

command, it fails. I get the following error:

core/lib/refinery/plugin.rb:93:in `initialize': You have a nil object when you didn't expect it! (NoMethodError)
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/bundler/gems/refinerycms-633a0939a864/core/lib/refinery/plugin.rb:13:in `new'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/bundler/gems/refinerycms-633a0939a864/core/lib/refinery/plugin.rb:13:in `register'
from /Users/mabounassif/Documents/Projects/blog/config/application.rb:56:in `block in '
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:34:in `call'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/finisher.rb:56:in `block in '
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/mabounassif/Documents/Projects/blog/config/environment.rb:5:in `'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:83:in `require_environment!'
from /Users/mabounassif/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands.rb:22:in `'
from script/rails:6:in `require'
from script/rails:6:in `

'

Tried debugging it for hours, but couldn't really figure out what's wrong, so I tried building my own engine separately, not by building a Rails engine but by creating controllers, models and views in the root application, the pieces worked separately, but I couldn't manage to add a tab to the admin dashboard to link to a certain utility of the plugin I'm trying to build.
I tried adding the following in by config/application.rb file:

config.after_initialize do
Refinery::Plugin.register do |plugin|
plugin.pathname = "news"
plugin.name = "refinerycms_news"
plugin.menu_match = /(admin|refinery)\/news(_items)?$/
plugin.url = {:controller => '/admin/news_items', :action => 'index'}
plugin.activity = {
:class => NewsItem,
:title => 'title',
:url_prefix => 'edit'
}
end
end

but with no luck, every time I try running the web server I ended up with the exact same error as the one described above.

Does anyone know if this is a bug? Or maybe I am doing something wrong.