Undefined method `find_plugins' in Rails 2.0.2

Hello Rails community! I just installed Rails 2.0.2. Before this, I
had version 1.2.6. I have several projects that have installed plugins
created by Pluginaweek. I’m not sure if my problem is Pluginaweek’s
fault, or a rails issue. I have several Pluginaweek plugins installed
(all up-to-date), all of which I’ll list below:

appable_plugins
loaded_plugins
plugin_dependencies
plugin_migrations
plugin_routing

I find these ENORMOUSLY handy. However, as soon as I moved to 2.0.2,
running my server broke. I couldn’t figure out exactly what the
problem was (as I couldn’t find anything about ‘find_plugins’ being
deprecated in the previous version), so I thought I’d turn to this
mailing list for help. As soon as I run script/server, I get the
following error:

krf$ script/server
=> Booting Mongrel (use ‘script/server webrick’ to force WEBrick) =>
Rails application starting on http://0.0.0.0:3000 => Call with -d to
detach => Ctrl-C to shutdown server ** Starting Mongrel listening at
0.0.0.0:3000 ** Starting Rails with development environment…
Exiting /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/
active_support/core_ext/module/aliasing.rb:31:in alias_method’:
undefined method find_plugins’ for class
`Rails::Initializer’ (NameError?)

from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/

active_support/core_ext/module/aliasing.rb:31:in alias_method_chain' from /Users/krf/src/Projects/kprojects/pluginPages2.0/vendor/plugins/ plugin_dependencies/lib/plugin_dependencies/extensions/initializer.rb: 47:inincluded’ from /Users/krf/src/Projects/kprojects/pluginPages2.0/
vendor/plugins/plugin_dependencies/lib/plugin_dependencies/extensions/
initializer.rb:45:in class_eval' from /Users/krf/src/Projects/ kprojects/pluginPages2.0/vendor/plugins/plugin_dependencies/lib/ plugin_dependencies/extensions/initializer.rb:45:inincluded’ from /
Users/krf/src/Projects/kprojects/pluginPages2.0/vendor/plugins/
plugin_dependencies/lib/plugin_dependencies/extensions/initializer.rb:
157:in include' from /Users/krf/src/Projects/kprojects/pluginPages2.0/ vendor/plugins/plugin_dependencies/lib/plugin_dependencies/extensions/ initializer.rb:157 from /Users/krf/src/Projects/kprojects/ pluginPages2.0/vendor/plugins/plugin_dependencies/lib/ plugin_dependencies/extensions/initializer.rb:156:inclass_eval’
from /Users/krf/src/Projects/kprojects/pluginPages2.0/vendor/plugins/
plugin_dependencies/lib/plugin_dependencies/extensions/initializer.rb:
156

    ... 50 levels...

from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/

server.rb:39 from /System/Library/Frameworks/Ruby.framework/Versions/
1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' from /System/Library/Frameworks/Ruby.framework/ Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:inrequire’ from script/server:3

Any idea what the problem is here? I have updated every gem I have
installed, and every app that is using these plugins works fine on
1.2.6, but as soon as I make it run in 2.0.2, it gives me that error.
Any suggestions would be wonderful, and I will provide any data
required.

On Mar 18, 7:59 am, Kyle [email protected] wrote:

plugin_routing

Well the stack trace you gave is to do with plugin_dependencies and I
happen to know that plugin loading changed quite a lot in 2.0.2 so I’m
not surprised that plugin_dependencies broke (and if loaded_plugins
broke I wouldn’t be surprised either).
This is the way that plugins often are: they rely on internal
implementation details and can get broken by major changes to rails.
See if the plugin author has updated their plugin for 2.0 and if not
try and fix it yourself. Or, see if 2.0 addressed some of your needs
(coming back to plugin loading, that changed a lot, so you may find
what comes as standard is enough).

Fred

Fred

Well, I knew the bit about how plugins work. However, I can’t find a
straightforward description of how plugin loading works in 2.0
anywhere! Unfortunately, Pluginaweek does not have plugins for 2.0. I
sent them an email, we’ll see what they say. As to fixing the plugin
itself, let me post the lines of code the error is complaining about:



43 module Initializer
44 def self.included(base) #:nodoc:
45 base.class_eval do
46 alias_method_chain :initialize, :plugin_dependencies
47 alias_method_chain :find_plugins, :plugin_dependencies
48 alias_method_chain :load_plugins, :plugin_dependencies
49 alias_method_chain :load_plugin, :plugin_dependencies
50 end
51 end


156 Rails::Initializer.class_eval do
157 include
PluginAWeek::PluginDependencies::Extensions::Initializer
158 end

Any ideas about what exactly to fix?

On Apr 6, 11:40 pm, Jesse H. [email protected] wrote:

As Frederick mentioned, the Rails plugin architecture underwent some
major changes for version 2.0. As a result, the method find_plugins no
longer exists. The function that used to be performed by
Rails::Initializer.find_plugins has apparently been split into another
class called Rails::Plugin::FileSystemLocator.

I am also working on getting plugin_dependencies to work in Rails
2.0.2. But it could be that the modifications required are nontrivial.
I will let you know if I come up with anything though.

Thank you Jesse! Please keep in touch… I’d love to have this stuff
working.

    Kyle

Can anyone help me here?
Ive got a standard edit page that accesses a model and saves back to
that model if it passes validation
most of the page uses the standard rails form helpers like text_area
et, but during the application occasionally i need to show a custom
form object that i want to populate with the model data /or the params
data if the model validation fails.

So most my page would use object like this
<%= text_field “listing”, “street_number” %>

but occasionally i need to do this:

ie its a field that i dont want to save back to the db bu it still
needs to get either the submitted params or the value from the db (in
that order)

can i shorten this part:

<%= params[:listing] ? params[:listing][:street_number] :
@listing.street_number %>

does rails store this info anywhere temporarily (ie a session) so i
can access it or do i have to write a method to access this ?
i am hoping it does similar to how it would store the validation
errors in @listing.errors

As Frederick mentioned, the Rails plugin architecture underwent some
major changes for version 2.0. As a result, the method find_plugins no
longer exists. The function that used to be performed by
Rails::Initializer.find_plugins has apparently been split into another
class called Rails::Plugin::FileSystemLocator.

I am also working on getting plugin_dependencies to work in Rails
2.0.2. But it could be that the modifications required are nontrivial.
I will let you know if I come up with anything though.

Yes.

In your controller you can say

@temp_street_no = params[:listing].blank? params[:listing]
[:street_number] : @listing.street_number

in the view you have

<%= text_field_tag ‘temp_street_no’, @temp_street_no %>

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.zenunit.com/

Sorry that should be

@temp_street_no = params[:listing].blank? ? params[:listing]
[:street_number] : @listing.street_number

and not what I’d previously written.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.zenunit.com/

Thanks Julian ,

With a bit more research i found rails is even smarter than this :slight_smile:
in this scenario rails automatically sets @listing.street_number in
the view to params[:listing][:street_number] if posted or
@listing.street_number if not
theres no need for the code below …

Therefore by the time the data gets to the view its already configured
the way you would imagine…thats damn awesome!
For this scenario just a simple <%= @listing.street_number %> in the
view worked with no additional code.

For anyone else if you ever needed to access the value in the
controller you still need to do this:

@temp_street_no = !params[:listing].nil? ? params[:listing]
[:street_number] : @listing.street_number

cheers for your help!

Adam

Umm… no it doesn’t.

You’d need to have: @listing = Listing.new(params[:listing])
in the controller’s respective action for that to take place. This
kind of loading is not automatic.

I’m guessing you had that, and didn’t give us all of the required
context when asking your question!?

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.zenunit.com/

cheers julian

On Tue, Apr 8, 2008 at 8:55 PM, Julian L. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs