问题标签 [scaffolding]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - 在 ASP.NET MVC 2 中与 SelectList 斗争
我有一个看起来像这样的模型:
我让 ASP.NET MVC 自动构建Html.DisplayForModel()
用于我的详细信息视图和Html.EditorForModel()
编辑视图的属性。
结果:
编辑视图效果很好。
Colors
显示为包含三个项目(红色、绿色和蓝色)的菜单,默认选择绿色。但是,对于详细信息视图,我得到“False True False”,这显然是
IsSelected
菜单中每个项目的值的列表。那绝对不是我想要的。我希望它只显示“绿色”。另一个问题是,如果我尝试
UpdateModel(sampleModel)
在控制器中执行此操作,则会收到错误消息“没有为此对象定义无参数构造函数”。这大概是因为Colors
是 aSelectList
,并且 没有无参构造函数SelectList
,所以无法完成绑定。
所以,我想我理解问题所在,但我真的可以为这种情况使用一个很好的解决方案,当你有带有外键的模型对象时,这似乎出现了很多。
一些问题:
- 如何
Colors
在“编辑”视图中显示为菜单,但在“详细信息”视图中仅显示为简单的字符串值(例如,“Green”)? - 更新包含 的模型时,如何防止“无参数构造函数”错误
SelectList
? - 如果我的 Model/ViewModel 实际上包含一个外键,
ColorId
而不是Colors
,那么让 Details 视图显示当前颜色的名称以及让 Edit 视图显示包含Color
我的数据库表。如果有帮助,我将使用 LinqToSql (SqlMetal) 来生成我的模型类。
cakephp - CakePHP HABTM:编辑一项会导致重新创建 HABTM 行,破坏额外数据
我在 CakePHP 中的 HABTM 关系有问题。
我有两个这样的模型:Department
HABTM Location
。一家大公司有许多建筑物,每栋建筑物提供的服务数量有限。每个建筑物也有自己的网页,因此除了 HABTM 关系本身之外,每个 HABTM 行还有一个url
字段,用户可以访问该字段以查找有关他们感兴趣的服务以及它如何在他们所在的建筑物中运行的其他信息有兴趣。
我已经像这样设置模型:
控制器完全无趣。
问题:
如果我编辑 a 的名称,则链接到该名称的Location
所有DepartmentsLocation
s 都将Location
使用空 URL 重新创建。由于模型指定 unique 为真,这也会导致所有较新的行覆盖较旧的行,这实质上会破坏所有 URL。
我想知道两件事:我可以停止吗?如果是这样,怎么做?
而且,在一个不太技术和更多抱怨的情况下:为什么会发生这种情况?对我来说,通过 Cake 编辑字段会引起这么多麻烦,这对我来说似乎很奇怪,因为我可以轻松地通过 phpMyAdmin,在Location
那里编辑名称,并得到我期望的结果。当我只是在一行中编辑一个字段时,为什么 CakePHP 会触摸 HABTM 数据?它甚至不是外键!
ruby-on-rails - RoR - 脚手架 - nil 的未定义方法“to_sym”:NilClass 只有编辑方法中的错误
我仅在我的 nifty_scaffold 的编辑页面中出现此错误。
这是 _form.html.erb
这是edit.html.erb
这是我的控制器:
有什么问题?我似乎找不到我的错误:-S。似乎它: - 正确获取数据 - 无法将 db-values 插入“编辑视图”字段。
我在脚手架中使用 :float、:string 和 :date 作为数据类型。
仅对于已完成的帖子,这是我的错误:NoMethodError in Progresses#edit
在第 6 行,代码日志结束...
编辑:这似乎是我的 routes.rb 中的错误。目前评论如下:
当我取消注释时,它也会在我的索引视图中出现错误。
出于某种原因,这被称为:' http: //127.0.0.1 :3001/progresses/1/edit ',不应该是:' http: //127.0.0.1 :3001/progresses/edit/ 1'吗?尽管似乎调用了“编辑视图”......在我看来,这也许是没有填写值的原因......
我的解决方案可能是什么?
activerecord - 如何在 SubSonic 3.0 中使用 SS2 中的脚手架?
我刚开始使用 SubSonic 3.0 版,我无法找到关于脚手架功能的足够信息。我知道脚手架包含在 2.x 版本中,但也可以与 3.x 一起使用。我的问题是,我必须在我的 SunSonic 3.x ActiveRecord 项目中包含什么,要引用什么以及添加到 web.config / App.config 什么才能使用 SubSonic 版本 3.x 中的脚手架功能。一个例子会很好。
谢谢你的帮助。通用汽车
ruby-on-rails - Ruby On Rails 脚手架加载错误
我正在使用我在第一章中挑选的一本名为“Head First Rails”的书学习 Ruby on Rails,它告诉我CRUD
使用以下命令创建我的程序:
我得到的错误是:
ruby: No such file or directory -- script/generate (LoadError)
有人可以解释我做错了什么。我对开发并不陌生,我是一名尝试学习 Ruby on Rails 的专业 C# 开发人员。
ruby-on-rails - RoR - # 的未定义方法“标题”
我是 RoR 的新手,正在关注 AWDwR 的书……
一切都很好,直到我开始了 Depot 项目....
使用创建产品模型
现在,当我查看页面http://localhost:3000/products时,它显示了一个通用页面,列表中没有任何内容以及添加新产品的链接...当我单击此链接时,我收到一个错误..错误如下跟随...
然后我检查了数据库..似乎根本没有创建标题列...做了一些搜索解决方案并且变得更加困惑...这似乎是脚手架和版本问题的问题.. .
提前致谢...
grails - Grails脚手架链接参考问题
我正在为两个域类的几个控制器使用脚手架:1 个扇区到 N 个项目:
当我生成相应的脚手架控制器时,我使用了模式(类)mgr:Sectormgr.groovy 和 Itemmgr.groovy。
问题是某些链接在某些生成的视图中无效,因为它假设我遵循控制器的默认名称。例如:
- 如果我转到 /sectormgr/show/20,与之关联的项目列表具有链接 /item/show/22,而不是 /itemmgr/show/22
有一个简单的解决方法吗?创建控制器时我是否遗漏了什么?
提前致谢
django - Django 的管理面板是否只是临时搭建的?
我已经成功地为内部用户使用了 Django 的管理面板有一段时间了,但是我最近在尝试自定义它时遇到了障碍,我很好奇我是否在它上面花费了太多时间。所以,我的问题是:
Django 的管理面板是否只是临时的脚手架,即仅在应用程序的初始开发期间使用,并被类似于 Rails 的脚手架的自定义代码替换?
显然,通过使用管理面板,我可以免费获得很多功能,并且随着新功能的添加,我也可以免费获得这些功能。其他人做什么?
ruby-on-rails - 无法向我的控制器类添加新功能(RoRails)
我试图在我的 Controller 类中定义一个新函数。我用脚手架编好了所有东西,效果还不错。但是现在,当我向控制器添加一个新功能、设置视图等时,它会说一些额外的错误(当我要求登录时尝试加载显示操作)。
我不是在做什么脚手架?谢谢
ruby-on-rails - Nutritions#new 中的 NoMethodError - nil:NilClass 的未定义方法“”
我的 nifty_scaffold 有一个错误...由于某种原因(没有更改任何标准代码,检查了 routes.rb,...),创建新的营养不起作用。
谁能解释我如何以及解决方案是什么?
我想我已经包含了所有必要的代码......
详细的错误是:未定义的方法`generated_methods' for nil:NilClass
路线包含:
视图:新
查看:_form
还有我的营养控制器
这是完整的跟踪
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/whiny_nil.rb:52:in method_missing' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:352:in
respond_to?' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/array/wrapper.rb:14:in wrap' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/active_record_helper.rb:174:in
error_messages_for' C:/ruby/lib/ruby/gems/1.8 /gems/actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:1012:in error_messages' D:/Workspace/Aptana/UltimateJournal/app/views/nutritions/_form.html.erb:3:in
_run_erb_app47views47nutritions47_form46html46erb_locals_form_object' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers /form_helper.rb:499:in fields_for' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:282:in
form_for' D:/Workspace/Aptana/UltimateJournal/app/views/nutritions/_form.html.erb:2:in _run_erb_app47views47nutritions47_form46html46erb_locals_form_object' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:34:in
send' C:/ruby/lib/ruby/gems/1.8/gems /actionpack-2.3.5/lib/action_view/renderable.rb:34:in render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:306:in
with_template' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:30 :在render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable_partial.rb:20:in
渲染' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:26:in benchmark' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in
ms' C:/ruby/lib/ruby/gems/1.8/gems /activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in realtime' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in
ms' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb :26:in benchmark' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable_partial.rb:19:in
render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/template.rb:205:in render_template' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable_partial.rb:44:in
render_partial' C:/ruby/lib/ruby/gems /1.8/gems/actionpack-2.3.5/lib/action_view/partials.rb:184:in render_partial' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:267:in
render' D:/Workspace/Aptana/UltimateJournal/app/views/nutritions/new.html.erb:3:in _run_erb_app47views47nutritions47new46html46erb' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:34:in
send' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:34:inrender' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:306:in
with_template' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:30:in render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/template.rb:205:in
render_template' C:/ruby/lib/ruby/gems/1.8/gems /actionpack-2.3.5/lib/action_view/base.rb:265:in render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:348:in
_render_with_layout' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:262 :in render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1250:in
render_for_file' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:945:in render_without_benchmark' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in
render' C:/ruby/lib/ruby/gems/1.8 /gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in ms' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in
realtime' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext /benchmark.rb:17:inms' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in
渲染'C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1326:indefault_render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1332:in
perform_action_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:617:in call_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:610:in
perform_action_without_benchmark' C:/ruby/lib/ruby/gems/1.8/gems /actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in perform_action_without_rescue' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in
ms' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb :10:in realtime' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in
ms' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in perform_action_without_rescue' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:160:in
perform_action_without_flash' C:/ruby/lib/ruby/gems /1.8/gems/actionpack-2.3.5/lib/action_controller/flash.rb:146:in perform_action' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in
send' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base .rb:532:in process_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in
process' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:inprocess' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in
调用'C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in
dispatch'C:/ruby/lib/ruby/gems/1.8 /gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in _call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in
build_middleware_stack' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb :29:in call' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:29:in
call' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in cache' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:9:in
cache' C:/ruby/lib /ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:28:in call' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in
call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib /action_controller/string_coercion.rb:25:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in
call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:incall' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in
调用'C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/cookie_store.rb:93:in call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in
call'C:/ruby/lib/ruby/gems/1.8 /gems/rack-1.0.1/lib/rack/lock.rb:11:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in
synchronize' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb :11:in call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in
call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34:in run' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in
call' C:/ruby/lib/ruby/gems /1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in
call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack /urlmap.rb:40:in each' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in
call' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb:17:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in
call' C:/ruby /lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:incall' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in
进程'C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:159:in each'C: process_client' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in
/ruby/lib/ruby/gems /1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in process_client' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in
run' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86 -mswin32-60/lib/mongrel.rb:285:in initialize' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in
new' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285 :在run' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in
初始化'C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:在new' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in
运行'C:/ruby/lib/ruby /gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in run' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:111 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire' script/server:3-e:2:in
加载'-e:2