Forum: Ruby on Rails Using link_to_remote/remote_function outside of a Controller

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.
13aaf0ef803bb063425d1bd6b913cac3?d=identicon&s=25 rickthemick (Guest)
on 2005-11-25 11:08
Hello!
I have a problem that is quite anoying!

In side my Controller it is no problem to use the
link_to_remote/remote_function function to produce html stuff to include
in my .rhtml file. BUT if I want to do this in another object, for
eample if I inside my controller (init_test) want to do like this:

my_dropdown->get_html

in which I want to perform the link_to_remote/remote_function function
and then return the html it produces it fails. I get the following error
message:

################################################################
 NoMethodError in Init_test#index

undefined method `url_for' for #<Dropdown:0xe431a8>

RAILS_ROOT: .
Application Trace | Framework Trace | Full Trace

#{RAILS_ROOT}bla/bla/.../Ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_view/helpers/javascript_helper.rb:279:in
`remote_function'
#{RAILS_ROOT}/app/controllers/dropdown.rb:24:in `get_html'
#{RAILS_ROOT}/app/controllers/init_test_controller.rb:26:in `index'
#{RAILS_ROOT}/app/controllers/init_test_controller.rb:16:in `index'

......

################################################################

and the call looks like this:
################################################################
#I uses remote_function within a select_tag funtion call:
 remote_function(:update => values_id,
                         :with => "val=+value",
                         :url => {:action => :update_blocks }))

################################################################

There might be a logical explanation to this behaviour but I cant figure
it out! Any help is appreciated!

/Rick
This topic is locked and can not be replied to.