Rails 3 中的就地编辑
有几个选项可用于在“显示”页面中就地编辑模型,即无需在“编辑”页面中加载表单。例如,请参阅 http://www.ruby-toolbox.com/categories/rails_in_place_editing.html 。
有没有人有过在 Rails 3 中使用这些选项(或其他选项)的经验?有什么指示或建议吗?
就我而言,我有一个相当长的表单,由可变数量的项目组成。从可用性的角度来看,在同一页面中编辑这些项目中的文本是很有意义的,而不需要为每个项目提供一个编辑按钮,将用户发送到特定项目的编辑页面。
There are a few options for editing a model in-place while in the Show page, i.e. without having to load a form in the Edit page. For example, see http://www.ruby-toolbox.com/categories/rails_in_place_editing.html.
Has anyone had any experience using any of these options (or others) in Rails 3? Any pointers or advice?
In my case, I have a fairly long form composed of a variable number of items. From a usability point of view, it makes good sense to edit the text in these items in the same page, instead of needing an Edit button for each one that sends the user to an edit page for the particular item.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
很好的问题!
in_place_editing 由 Rails 创建者 dhh 编写。它由 Rails 核心团队维护。所以它当然应该被研究。
Hobo 是一个大型框架,具有前端和中心就地编辑功能。这是一个流畅的软件包,但可能超出您想要或需要的范围。
针对 Rails 3 进行了更新
Railscasts 的 Ryan 推荐 最佳位置 gem。请参阅 Railscast,其中包含示例代码和更多信息。
Excellent question!
in_place_editing is by dhh, Rails creator. It's maintained by the Rails core team. So it certainly should be looked into.
Hobo is a large framework that features in-place editing front and center. It's a smooth package but may be more than what you want or need.
Updated for Rails 3
Ryan of Railscasts recommends the Best in Place gem. See the Railscast with sample code and more info.
当然这对我来说很有意义。我一直这样做。
例如,我正在研究一个复杂的多态嵌套模型表单,它只有两个视图。一个索引,以及一个用于动态向其添加更多属性的部分。
如果您了解 AJAX,那么这确实可以帮助您的 UI,因为您的用户甚至不必单击保存按钮。
实现这一点的最低限度。设置一个index.html.erb,其中包含您的表单。
在您的控制器中,您可以像这样指定您的操作:
Sure it makes sense to me. I do it all the time.
For example, I am working on a complex polymorophic nested model form and it only has two views. An index, and a partial for dynamically adding more attributes to it.
If you know AJAX, that can really help your UI in that your users will not even have to click a save button.
To accomplish a bare minumum of this. Set up an index.html.erb with your form inside it.
In your controller, you could specify your actions like so :