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:
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:in `included' 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:in `included' 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:in `class_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:in
`require' 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.
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).
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
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
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.
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" %>
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
With a bit more research i found rails is even smarter than this
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: