- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我一直在做一些研究,但我似乎找不到我做错了什么。
我已经安装了 simple_form 和 nested_form gem,但是当我使用 link_to_add 或 remove 时,我得到了同样的错误。
代码如下
/fields.html.erb
<%= render 'shared/error_messages', :object => f.object %>
<%= f.input :nombre_cliente, :label => 'Nombre del cliente:', :as => :string %>
<%= f.input :mail_cliente, :label => 'E-mail del cliente:', :as => :string %>
<%= f.input :empresa_cliente, :label => 'Empresa:', :as => :string %>
<%= f.input :confirmada, :label => 'Ha sido confirmada por el cliente.' %>
<%= f.input :confirmacion_cliente, :label => 'Fecha de confirmacion por el cliente:', :as => :date %>
<b>something here</b>
</br></br>
<%= f.simple_fields_for :producto_de_cotizacion do |productos| %>
<%= productos.input :nombre %>
<%= productos.input :descripcion %>
<%= productos.input :precio%>
<%= productos.link_to_remove("Eliminar producto") %>
<% end %>
<%= f.link_to_add "Agregar producto", :producto_de_cotizacion %>
其中一些是西类牙语,但我认为它可以理解
这是我得到的实际错误:
undefined method `link_to_remove' for < SimpleForm::FormBuilder:0x9ccf37c>
这就是 _fields.html.erb 的全部内容,但是它被 new.html.erb 和 edit.html.erb 文件调用,它们基本上是相同的,我将发布编辑文件:
<h1>Agregar Cotizacion</h1>
<div id='admin_view'>
<%= simple_form_for @cotizacion, :html => {:multipart => true} do |f| %>
<%= render "fields", :f => f %>
<%= f.button :submit, 'Actualizar Cotizacion' %>
<% end%>
</div>
将其更改为 simple_nested_form 后出现新错误:
undefined method `klass' for nil:NilClass
这是堆栈
activesupport (3.0.7) lib/active_support/whiny_nil.rb:48:in `method_missing'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/builder_mixin.rb:23:in `block in link_to_add'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/view_helper.rb:37:in `call'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/view_helper.rb:37:in `block in after_nested_form_callbacks'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/view_helper.rb:36:in `map'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/view_helper.rb:36:in `after_nested_form_callbacks'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/view_helper.rb:13:in `simple_nested_form_for'
app/views/cotizacions/edit.html.erb:3:in `_app_views_cotizacions_edit_html_erb__855809706_86735240_354753338'
actionpack (3.0.7) lib/action_view/template.rb:135:in `block in render'
activesupport (3.0.7) lib/active_support/notifications.rb:54:in `instrument'
actionpack (3.0.7) lib/action_view/template.rb:127:in `render'
actionpack (3.0.7) lib/action_view/render/rendering.rb:59:in `block in _render_template'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.7) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.7) lib/action_view/render/rendering.rb:56:in `_render_template'
actionpack (3.0.7) lib/action_view/render/rendering.rb:26:in `render'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:115:in `_render_template'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:109:in `render_to_body'
actionpack (3.0.7) lib/action_controller/metal/renderers.rb:47:in `render_to_body'
actionpack (3.0.7) lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:102:in `render_to_string'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:93:in `render'
actionpack (3.0.7) lib/action_controller/metal/rendering.rb:17:in `render'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.0.7) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/peanut/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
activesupport (3.0.7) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
activerecord (3.0.7) lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:39:in `render'
meta-tags (1.2.4) lib/meta_tags/controller_helper.rb:28:in `render_with_meta_tags'
actionpack (3.0.7) lib/action_controller/metal/implicit_render.rb:14:in `default_render'
actionpack (3.0.7) lib/action_controller/metal/implicit_render.rb:6:in `send_action'
actionpack (3.0.7) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.7) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.7) lib/active_support/callbacks.rb:451:in `_run__761686272__process_action__750077467__callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:94:in `run_callbacks'
actionpack (3.0.7) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.7) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.7) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.7) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.7) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.7) lib/action_controller/metal.rb:178:in `block in action'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:89:in `optimized_each'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:493:in `call'
warden (0.10.7) lib/warden/manager.rb:35:in `block in call'
warden (0.10.7) lib/warden/manager.rb:34:in `catch'
warden (0.10.7) lib/warden/manager.rb:34:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.4) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.7) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.7) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.7) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.7) lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.4) lib/rack/sendfile.rb:106:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.7) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.4) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.7) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.4) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.4) lib/rack/lock.rb:11:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.7) lib/rails/application.rb:168:in `call'
railties (3.0.7) lib/rails/application.rb:77:in `method_missing'
railties (3.0.7) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.4) lib/rack/content_length.rb:13:in `call'
rack (1.2.4) lib/rack/handler/webrick.rb:52:in `service'
/home/peanut/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/peanut/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/peanut/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
最佳答案
使用 :locals => { :f => f }
编辑:更改我的答案。
我刚刚意识到你正在使用:
simple_form_for
将其更改为
simple_nested_form_for
这允许您使用 nested_form
选项(link_to_add
、link_to_remove
等)。
干杯!
关于ruby-on-rails - #<SimpleForm::FormBuilder> 的未定义方法 'link_to_add\remove',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8609270/
注意:根据 ECMAScript5.1, section 15.1.1.3 , window.undefined 是只读的。 现代浏览器正确地实现了这一点。例如:Safari 5.1、Firefox
我用谷歌搜索,检查了所有常见的响应。这些脚本似乎顺序正确(它们在 the demo 中以相同的顺序工作)但由于某种原因,当我尝试实现它时,我得到了错误。 我有一个 paste bin用我完整的页面代码
我有以下代码: simpleExample.html: Simple example Open the Console. js/simpleExampleJS.
所以我对 typescript 很陌生。 这是我的 tsconfig.json 文件的样子, 我什至不知道那些“例子”是从哪里来的 这是我在浏览器中遇到的错误 这是我的 package.json 最佳
我被 TypeScript 错误困住了: Failed to compile. undefined TypeScript error in undefined(undefined,undefined)
我已将 onlcick 事件附加到表单的提交按钮以覆盖默认的 POST 请求,但在使其正常工作时遇到了一些问题。 我想要的是点击添加到购物车的商品,但只显示模式确认而不刷新页面。 这段代码在我的静态示
我已经完成了这个link .但是给定的解决方案并没有解决我的问题。所有经验丰富的人都建议使用 getActivty().getApplicationContext()。但我使用的是普通类(class)
我有一个应用程序,其中 webpack 配置为模块 bundler ,babel 作为我的 js 编译器。全部都在 Node 引擎上。我设置当我运行 npm run dev 时,将会发生以下流程: w
我正在尝试在浏览器中呈现网址的 JSON 数据,但它在 div 中显示为 undefined, undefined .当我将其响应放入console.log时对象及其数据出现,因此它出现在控制台和浏览
为什么我会收到 Cannot invoke an object which is possibly 'undefined'即使在我检查了 func 之后,Typescript 也会出错引用不是未定义的
我想使用airbnb的eslint修改我的代码结构。我已遵循 eslint-config-airbnb 中给出的说明。启动命令后npm run lint,结果由 'fetch' is not Defi
这个问题在这里已经有了答案: What is the consequence of this bit of javascript? (4 个答案) 关闭 9 年前。 我看到一些 jQuery 脚本嵌
我一直收到这个 pouchDB 错误,我不知道这是怎么回事。 Error: connect ENFILE 127.0.0.1:5984 - Local (undefined:undefined)
import os from os.path import abspath, dirname import sys # Set up django project_dir = abspath(dirn
在 javascript 中,要检查变量是否从未创建过,我们只需执行 if (typeof MyVariable !== "undefined"){ ... } 我想知道如何在 CoffeeScrip
我正在尝试编译 FreeLing,它使用 CMake 来检测 Boost。这是负责它的代码: find_package(Boost COMPONENTS regex filesystem thre
我收到“JQUERY 未定义”错误。你有什么想法吗(代码如下)。 $(document).ready(function() { window.print();
无论我是否将 jQuery $.ajax 调用放入 $(document).ready(function() { 中,我都会收到此错误。这是在 ASP.NET MVC .cshtml 文件上.
我正在构建的网站上遇到问题,但数据表不存在加载(在服务器上)但在本地主机(xamp)上工作正常。 Firefox 会抛出错误“$ 未定义”。 我用谷歌搜索了这些错误,我发现一个 friend 的解决方
当我在 $(document).ready 之前明确包含 jQuery 库时,我无法弄清楚为什么它仍然无法识别 jQuery 语法
我是一名优秀的程序员,十分优秀!