Forum: Ruby on Rails AJAX: link_to_remote problem

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.
Cc04e21896547a3390823825fe5992e7?d=identicon&s=25 Willi Weichselbaumer (williw)
on 2006-01-11 18:11
I use:
<%= link_to_remote("Update",
	           :update => 'mydiv',
		   :url => { :action => :create, :host => 'rails' }) %>


which generates the following:

<a href="#" onclick="new Ajax.Updater('mydiv', '/account/create',
{asynchronous:true, evalScripts:true}); return false;">Update</a>

as a result /account/create is routed to http:/localhost//account/create
(which runs mod Python) and
not as I would like (and need) to http://rails/account/create

Using the following:

<%= link_to_remote("Update 2",
		   :update => 'mydiv',
		   :url => 'http://rails/account/create' ) %>

doesn't work either. It results in using the correct url, but the url
parameter seems to be not correct:

TypeError in Account#create
can't dup NilClass
RAILS_ROOT: C:/Projects/Athena/rails/public/../config/..

Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/vendor/plugins/javascript_generator_templates/lib/add_rjs_to_action_controller.rb:41:in
`dup'


the controller contains:

  def create
    render :layout => false
  end

create.rhtml contains:

<em>Hello from Ajax!</em>

new.rhtml contains:
<%= javascript_include_tag :defaults %>

<%= link_to_remote("Update",
	           :update => 'mydiv',
		   :url => { :action => :create, :host => 'rails' }) %>
<div id="mydiv"><p>This text will be changed 2</p></div>

Does anybody have any idea on how to work around this problem?

Thanks,

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