Forum: Ruby on Rails Strange dependency error after going Ruby1.8.6, Rails 2.1.0 -> Ruby1.8.7, Rails 2.1.2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
30ce2e2757bccd460c80c25b68f85096?d=identicon&s=25 Java (Guest)
on 2008-10-31 16:55
(Received via mailing list)
Hi,

I'm getting an error I just can't find any cause for.
The error is "A copy of ApplicationHelper has been removed from the
module tree but is still active!" and gets thrown
in a Template that uses a method defined in my ApplicationHelper. The
error occurs only in development mode.

The error did not occur before my switch to Ruby 1.8.7 and Rails 2.1.2
minutes ago.
I have absolutely no clue about what could be causing this.
The problem occurs on windows as well as MacOS X 10.5

Any help would be appreciated.

regards

Jan

Stacktrace:

ActionView::TemplateError (A copy of ApplicationHelper has been
removed from the module tree but is still active!) on line #57 of
photosessions/show.html.erb:
54:                     </td>
55:                     <td class="cell-select">
56:                         <select name="formats[]" class="format">
57:                             <%=
price_options_for(@photosession.typ) %>
58:                         </select>
59:                     </td>
60:                     <td class="cell-remove">

    /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/
active_support/dependencies.rb:250:in `load_missing_constant'
    /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/
active_support/dependencies.rb:468:in `const_missing'
    app/helpers/application_helper.rb:20:in `price_options_for'
    app/views/photosessions/show.html.erb:57:in
`_run_erb_47app47views47photosessions47show46html46erb'
    /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/
base.rb:342:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/
base.rb:342:in `execute'
    /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/
template_handlers/compilable.rb:29:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/
template_handlers/compilable.rb:29:in `render'
    /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/
template.rb:35:in `render'
    /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/
template.rb:22:in `render_template'
    /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/
base.rb:248:in `render_file'
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2008-10-31 23:02
(Received via mailing list)
Java wrote:
> I have absolutely no clue about what could be causing this.
> ActionView::TemplateError (A copy of ApplicationHelper has been
>
>     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/
> active_support/dependencies.rb:250:in `load_missing_constant'
>     /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/
> active_support/dependencies.rb:468:in `const_missing'
>     app/helpers/application_helper.rb:20:in `price_options_for'

Could you please post line 20 of application_helper.rb


--
Rails Wheels - Find Plugins, List & Sell Plugins -
http://railswheels.com
30ce2e2757bccd460c80c25b68f85096?d=identicon&s=25 Java (Guest)
on 2008-11-01 10:01
(Received via mailing list)
Oh, damn, sorry, of course. I forgot, here it is:

19  def price_options_for(sessiontype)
20    options_for_select
(Price.find_all_by_sessiontype(sessiontype).map { |p|
21      ["#{p.format} #{german_price(p.price, true)}", p.format]
22    })
23  end

Other Methods in the helper never throw an exception..
After posting my original message I poked around the code a little bit
further.
I think accessing the "Price" model might cause the error.
But, uh, that's not something that should happen, right?
30ce2e2757bccd460c80c25b68f85096?d=identicon&s=25 Java (Guest)
on 2008-11-01 10:31
(Received via mailing list)
Yeah, I can confirm that.
I moved the

  Price.find_all_by_sessiontype(sessiontype)

out of the helper method and now everything seems to work.

I still think this error shouldn't have happened in the first place.
I tried to investigate, but the dependency loader is so
full of Voodoo that I can't figure it out.
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2008-11-01 11:15
(Received via mailing list)
Java wrote:
> Yeah, I can confirm that.
> I moved the
>
>   Price.find_all_by_sessiontype(sessiontype)
>
> out of the helper method and now everything seems to work.
>
> I still think this error shouldn't have happened in the first place.
> I tried to investigate, but the dependency loader is so
> full of Voodoo that I can't figure it out.

Yes, it shouldn't have happened. To pinpoint the blame,
can you try downgrading one of Rails or Ruby? It'd be
easiest to set RAILS_GEM_VERSION = '2.1.0' in environment.rb.

--
Rails Wheels - Find Plugins, List & Sell Plugins -
http://railswheels.com
30ce2e2757bccd460c80c25b68f85096?d=identicon&s=25 Java (Guest)
on 2008-11-02 23:41
(Received via mailing list)
Ok, I tried Rails 2.1.2, 2.1.1 and 2.1.0
The error shows up in all versions.
I guess that means it has something to do with the Ruby Update (1.8.6 -
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-02 23:55
(Received via mailing list)
On Nov 2, 10:40 pm, Java <jan.var...@googlemail.com> wrote:
> Ok, I tried Rails 2.1.2, 2.1.1 and 2.1.0
> The error shows up in all versions.
> I guess that means it has something to do with the Ruby Update (1.8.6 -
>
> > 1.8.7)?

Typically this happens when you're mixing things that are reloading
between requests and things that aren;t (in production nothing is
reloaded so this problem can't happen).
See
http://groups.google.com/group/rubyonrails-core/br...

Fred
30ce2e2757bccd460c80c25b68f85096?d=identicon&s=25 Java (Guest)
on 2008-11-07 19:23
(Received via mailing list)
Ah, yes, thanks.

I'll try to investigate this a bit further.
The case you linked to describes a different problem though, it seems.
In my case the model (Price) and the ApplicationHelper are fairly
vanilla,
not loading any fancy external libraries through ways untrackable by
Rails dependency mechanisms.
That's what's bothering me so much (after all, I got my code running
by pulling the Price reference out of the helper),
all this seems to indicate a bug somewhere in the dependency/
autoreload mechanism.

Jan
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-07 20:41
(Received via mailing list)
On Nov 7, 6:22 pm, Java <jan.var...@googlemail.com> wrote:
> Ah, yes, thanks.
>
> I'll try to investigate this a bit further.
> The case you linked to describes a different problem though, it seems.
> In my case the model (Price) and the ApplicationHelper are fairly
> vanilla,
> not loading any fancy external libraries through ways untrackable by
> Rails dependency mechanisms.

You can also confuse the dependency system by using require when you
could/should be using require_dependency.

> That's what's bothering me so much (after all, I got my code running
> by pulling the Price reference out of the helper),
> all this seems to indicate a bug somewhere in the dependency/
> autoreload mechanism.

Hard to say from what I've seen.

Fred
30ce2e2757bccd460c80c25b68f85096?d=identicon&s=25 Java (Guest)
on 2008-11-09 12:53
(Received via mailing list)
Well, the andand gem seems to be the culprit (http://github.com/
raganwald/andand/tree/master/lib/andand.rb).

I'll contact the author about this.
30ce2e2757bccd460c80c25b68f85096?d=identicon&s=25 Java (Guest)
on 2008-11-09 18:22
(Received via mailing list)
Ah, sorry, that was a little quick.
Actually the bug is caused by the resource_controller plugin.
My bad.
I posted a report in the resource_controller group.

regards

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