Forum: Rails Engines Rails 2.0.2 upgrade difficulties

6e0df11a3326dfcf8e81f05ffd3f5502?d=identicon&s=25 Sean Schofield (Guest)
on 2008-01-03 02:00
(Received via mailing list)
Getting a routing error when I tried upgrading to Rails 2.0.2.

... vendor/plugins/engines/lib/engines/rails_extensions/routing.rb:69:in
`from_plugin': You have a nil object when you didn't expect it!
(NoMethodError)
The error occurred while evaluating nil.routes_path  from ...........

Any ideas on this?  Its possible there is a 2.0 issue with my code or
another plugin but the logs show only the following ...

Attempting to copy plugin assets from
'..............vendor/plugins/calendar_date_select/public' to
'............ public/plugin_assets'
** has_many_polymorphs: rails environment detected
** has_many_polymorphs: loaded ok

TIA,

Sean
Bfccdb1c41c334fec20e5ede3a7ccfcc?d=identicon&s=25 Andrew Roth (andrewroth)
on 2008-01-03 02:21
(Received via mailing list)
I had that problem, and it was that I had a from_plugin call in my app's
routes to a plugin that actually didn't exist.  If you're sure the
plugin
does exist, can you try editing that file and make it like:

module Engines::RailsExtensions::Routing
  # Loads the set of routes from within a plugin and evaluates them at
this
  # point within an application's main <tt>routes.rb</tt> file.
  #
  # Plugin routes are loaded from <tt><plugin_root>/routes.rb</tt>.
  def from_plugin(name)
    map = self # to make 'map' available within the plugin route file

    # add these debug stmts
    Engines.logger.debug "Trying to load plugin #{name}'s routes."
    Engines.logger.debug "Engines loaded so far:
#{Engines.plugins.collect
(&:name).inspect}"

    routes_path = Engines.plugins[name].routes_path
    Engines.logger.debug "loading routes from #{routes_path}"
    eval(IO.read(routes_path), binding, routes_path) if File.file
?(routes_path)
  end
end

....

and let us know what the result of those lines is?

Can you also paste in the full stack trace?

thnx

-Andrew
6e0df11a3326dfcf8e81f05ffd3f5502?d=identicon&s=25 Sean Schofield (Guest)
on 2008-01-03 16:15
(Received via mailing list)
> I had that problem, and it was that I had a from_plugin call in my app's
> routes to a plugin that actually didn't exist.  If you're sure the plugin
> does exist, can you try editing that file and make it like:

The plugin definitely exists.  The mappings worked fine until I
upgraded to Rails 2.0.2 and the Engines trunk.

> and let us know what the result of those lines is?

Trying to load plugin railscart's routes.
Engines loaded so far: ["engines", "acts_as_list",
"calendar_date_select", "has_many_polymorphs", "paginating_find"]

> Can you also paste in the full stack trace?

9152
=> Booting WEBrick...
D:/client-work/gp2/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb:74:in
`from_plugin': You have a nil object when you didn't expect it!
(NoMethodError)
The error occurred while evaluating nil.routes_path  from
D:/client-work/gp2/config/routes.rb:18
  from
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1250:in
`draw'
  from D:/client-work/gp2/config/routes.rb:1
  from
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in
`load'
  from
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in
`load'
  from
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in
`new_constants_in_without_injection'
  from
D:/client-work/gp2/vendor/plugins/has_many_polymorphs/lib/has_many_polymorphs/dependencies.rb:29:in
`new_constants_in'
  from
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in
`load'
   ... 46 levels...
  from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
  from ./script/server:3
  from -e:4:in `load'
  from -e:4


> -Andrew

Sean
402602a60e500e85f2f5dc1ff3648ecb?d=identicon&s=25 Sven Fuchs (Guest)
on 2008-01-03 17:48
(Received via mailing list)
Am 03.01.2008 um 16:15 schrieb Sean Schofield:
>> I had that problem, and it was that I had a from_plugin call in my
>> app's
>> routes to a plugin that actually didn't exist.  If you're sure the
>> plugin
>> does exist, can you try editing that file and make it like:
>
> The plugin definitely exists.  The mappings worked fine until I
> upgraded to Rails 2.0.2 and the Engines trunk.

Just guessing, but ... maybe it isn't a valid plugin in terms of Rails
2.0? I.e. does it have an init.rb file and/or a lib subdirectory?

It obviously is not present in Engines.plugins:

> Trying to load plugin railscart's routes.
> Engines loaded so far: ["engines", "acts_as_list",
> "calendar_date_select", "has_many_polymorphs", "paginating_find"]

We might want to raise a more meaningful error or log a warning in
this case ...


--
sven fuchs      svenfuchs@artweb-design.de
artweb design    http://www.artweb-design.de
gr├╝nberger 65    + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin    + 49 (0) 171 - 35 20 38 4 (mobile)
6e0df11a3326dfcf8e81f05ffd3f5502?d=identicon&s=25 Sean Schofield (Guest)
on 2008-01-03 23:12
(Received via mailing list)
> Just guessing, but ... maybe it isn't a valid plugin in terms of Rails
> 2.0? I.e. does it have an init.rb file and/or a lib subdirectory?

Yes it has both.  Is that a problemo?

Sean
402602a60e500e85f2f5dc1ff3648ecb?d=identicon&s=25 Sven Fuchs (Guest)
on 2008-01-04 00:17
(Received via mailing list)
Am 03.01.2008 um 23:12 schrieb Sean Schofield:
>> Just guessing, but ... maybe it isn't a valid plugin in terms of
>> Rails
>> 2.0? I.e. does it have an init.rb file and/or a lib subdirectory?
>
> Yes it has both.  Is that a problemo?

Whoops, no. Sorry for not being more clear.

Rails regards a directory with an init.rb and/or a lib subdir as a
valid plugin. As such it should be added to the Engines.plugins hash.
If it's not there when routing is initialized, something pretty weird
is going on.



--
sven fuchs      svenfuchs@artweb-design.de
artweb design    http://www.artweb-design.de
gr├╝nberger 65    + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin    + 49 (0) 171 - 35 20 38 4 (mobile)
6e0df11a3326dfcf8e81f05ffd3f5502?d=identicon&s=25 Sean Schofield (Guest)
on 2008-01-04 16:29
(Received via mailing list)
OK I found out the root of the problem (actually Andrew Roth helped me
find it during a brief chat last night.)

I'm using active_merchant in my project and I'm requiring it from the
railscart plugin (that's the plugin that was coming up nil.)
Ultimately active_merchant does the following in integrations.rb:

Inflector.inflections do |inflect|
  inflect.uncountable 'bogus'
end

Somehow this is kicking off the mapping stuff before it should.  I
don't know enough about Rails, plugins or Engines to say why this is
happening but that's what I'm observing.

If I move "require 'active_merchant'" from railscart's init.rb and
move into the application's environment.rb everything works fine.  The
mappings are loaded and no nasty stack trace.

Weird.  But resolved now.  Thanks to everyone for all of the help.

Sean
Bec38d63650c8912b6ba9b557fb953b9?d=identicon&s=25 Roger Pack (rogerdpack)
on 2008-01-12 23:26
> Attempting to copy plugin assets from
> '..............vendor/plugins/calendar_date_select/public' to
> '............ public/plugin_assets'
As a side note this seemed to be repeated over and over in
egines-=possibly without harm?
0f95e541e4ef8296fc157f67c93cfc08?d=identicon&s=25 Tim Booher (tbbooher)
on 2008-04-17 02:41
Wow, thank you so much for posting this. This is very helpful. I was
frustrated by the same error.

thanks again!

Tim

Roger Pack wrote:
>> Attempting to copy plugin assets from
>> '..............vendor/plugins/calendar_date_select/public' to
>> '............ public/plugin_assets'
> As a side note this seemed to be repeated over and over in
> egines-=possibly without harm?
0f95e541e4ef8296fc157f67c93cfc08?d=identicon&s=25 Tim Booher (tbbooher)
on 2008-04-17 12:18
Sorry, but I can't get this to work:

When starting webrick I get the following error:
/vendor/plugins/engines/lib/
engines/rails_extensions/routing.rb:69:in `from_plugin': You have a
nil object when you didn't expect it! (NoMethodError)
The error occurred while evaluating nil.routes_path
from /config/routes.rb:4
from C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/routing.rb:1250:in `draw'
from /config/routes.rb:1
 ... lots of levels...
from C:/ruby/bin/rdebug-ide:16:in `load'
from C:/ruby/bin/rdebug-ide:16

engines (with savage beast) was working fine before this . . . but now
the ruby error is vastly above my understanding of these plugins. if i
comment out:

  map.from_plugin :savage_beast

in my routes.rb file, then everything works.

any help here is greatly appreciated -- I don't understand engines as
well as I should, and I can't properly troubleshoot this.
4b668cd6e6483ce020d98a5e43fb5ac7?d=identicon&s=25 Ron Evans (deadprogrammer)
on 2008-04-28 00:40
In my case, I also had troubles with "the big upgrade". I discovered
this thread here, in particlar  Sean Schofield's post about the active
merchant plugin's inflector problem, and taking inspiration from that, I
added the following code to my environment.rb, inside the config block:

config.plugins = [ :all, :active_merchant ]

Now my application is loading correctly! Thanks to all who explored this
issue... it was a real pain.

Ron Evans
http://www.deadprogrammersociety.com

> Tim Booher wrote:
> Sorry, but I can't get this to work:
>
> When starting webrick I get the following error:
> /vendor/plugins/engines/lib/
> engines/rails_extensions/routing.rb:69:in `from_plugin': You have a
> nil object when you didn't expect it! (NoMethodError)
> The error occurred while evaluating nil.routes_path
> from /config/routes.rb:4
> from C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
> action_controller/routing.rb:1250:in `draw'
> from /config/routes.rb:1
>  ... lots of levels...
> from C:/ruby/bin/rdebug-ide:16:in `load'
> from C:/ruby/bin/rdebug-ide:16
>
> engines (with savage beast) was working fine before this . . . but now
> the ruby error is vastly above my understanding of these plugins. if i
> comment out:
>
>   map.from_plugin :savage_beast
>
> in my routes.rb file, then everything works.
>
> any help here is greatly appreciated -- I don't understand engines as
> well as I should, and I can't properly troubleshoot this.
0f95e541e4ef8296fc157f67c93cfc08?d=identicon&s=25 Tim Booher (tbbooher)
on 2008-12-27 18:11
Excellent, thank you for your very helpful reply.

Tim
This topic is locked and can not be replied to.