【发布时间】:2011-04-28 09:02:39
【问题描述】:
我被困住了;我进行了搜索,但找不到有关如何使该项目正常工作的指针。我的 index.html.erb 上有一个表格:
<html> <head>
<title>Ajax List Demo</title> <h1>Listing posts</h1>
<%= javascript_include_tag "prototype" %> </head> <body>
<h3>Add to list using Ajax</h3>
<% form_tag ( :remote=>true, :update => 'my_list', :action => :list , :method=>:post, :format =>:xml ) do %>
Enter the url:
<%= text_field_tag 'url' ,'', :size => 80 %>
<%= submit_tag "Find" %>
<% end %>
<div id="my_list"><%= render :partial => 'profiles/list' %></div> </body> </html>
现在我有一个名为 my_list 的 div。当我提交表单时,我希望我的部分 _list.html.erb(在配置文件目录内,也尝试过主目录)使用列表的结果进行更新。
我家的控制器有这个方法:
def list
puts "here!!!!"
reader = Reader.new
@profiles = reader.processURL(params[:url])
render :partial=>'profiles/list', :locals => { :profiles => @profiles}
end
我最终得到了这个错误:
ActionView::MissingTemplate (Missing partial profiles/list with {:locale=>[:en, :en], :handlers=>[:rjs, :builder, :rhtml, :rxml, :
erb], :formats=>[:xml]} in view paths "C:/Users/....tree/app/views"):
app/controllers/home_controller.rb:22:in `list'
Rendered C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/missing_template.erb
within rescues/layout (1.0ms)
谁能帮助我或向我发送正确的方向以了解如何在表单提交时通过 Rails 更新 div 渲染?再次感谢。
【问题讨论】:
标签: ruby-on-rails ajax ruby-on-rails-3