我有一个 Rails 2 站点,我正在尝试向其中添加表单处理程序,但在将 html 表单字段转换为表单处理程序字段时遇到了问题。
表单代码以:
<% form_for @newsavedmap, :html=>{:id=>'createaMap'} do |f| %>
当我尝试类似的事情时,我不断收到错误
<%= text_field :newsavedmap, :html=>{ :value => 'New Map', :name=>'newsavedmapname', :id=> 'savedmap_name', :size => '30' } %>
错误:
ActionView::TemplateError (wrong number of arguments (1 for 2)) on line #284 of app/views/layouts/maptry.html.erb:
这里是字段。如何将这些转换为 Rails 2 中的表单处理程序字段?
<input id="savemap_name" name="newsavedmapname" size="30" type="text" value="New Map"></p>
<select id="startdrop" name="startthere">
<OPTIONS HERE>
</select>
<select multiple id="waypoints" class="mobile-waypoints-remove" name="waypointsselected[]">
<OPTIONS HERE>
</select>
感谢您的任何帮助,您可以提供!
编辑 Text_Field 的 1 个错误代码
使用Bigxiang的方法,我得到
Processing NewsavedmapsController#create (for IP at Date Time) [POST]
Parameters: {"endhere"=>"", "endthere"=>"SAMPLE ADDRESS 1", "newsavedmap"=>{"newsavedmapname"=>"test Map"}, "startthere"=>"SAMPLE ADDRESS 2", "starthere"=>"", "optimize"=>"on"}
ActiveRecord::UnknownAttributeError (unknown attribute: newsavedmapname)
"newsavedmap"=>{"newsavedmapname"=>"test Map"} 的行应该只是读
"newsavedmapname"=>"test Map"
我怎样才能做到这一点?我的控制器开始于:
def create
@newsavedmap = Newsavedmap.new(params[:newsavedmap])
@newsavedmap.name = params[:newsavedmapname]